Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Solves the 'cross-domain AJAX post' similar to how Facebook does it

Ajax iframe Bridge

This is a simple bridge for making cross-domain AJAX requests to a specific remote host, probably your API hosted on a different domain from your main app.

Here's how you use it:

  1. Add bridge.js and iframe.html to the list of files hosted by your API.
  2. In the API wrapper you provide to your clients, do the following:

        <script src="path/to/bridge.js"></script>
            //... your stuff
  3. Whenever, in your API, you would have done $.ajax({...}), use Bridge.ajax({...}) instead.

What's awesome about this:

  • you are good to make POST requests across domains
  • callbacks to success/error will work.


  • There's a TODO in the code explaining where to ensure that you are taking care to secure yourself from cross-domain attacks. Your implementation may well differ from ours.
  • test* provides a simple testing framework. You only need iframe.html and the bridge.js to be included in the things provided by your API.
Something went wrong with that request. Please try again.