Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Solves the 'cross-domain AJAX post' similar to how Facebook does it
JavaScript
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
LICENSE
README.md
bridge.js
iframe.html
test.html
testserver.js

README.md

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>
        <script>
          $(document).ready(function(){
            Bridge.init("http://your-domain.com/path-to-your/iframe.html",
                        "http://your-domain.com");
            //... your stuff
          });
        </script>
    
  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.

Notes:

  • 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.