A jQuery plugin to allow Cross Origin AJAX requests with no need to write a local proxy.
Just add the <script src="..."> tag to your page header and you are ready to use jQuery.ajax() with cross domain calls support.
Download jQuery ajax-cross-origin Plugin. This package includes the js plugin script, HTML test page with examples.
In order maintain this site and keep it running, we ask for symbolic donation before you download the sources. You can donate as much as you want, even $1 is enough. The package contains the source code files include instructions and a test page with samples.
This example illustrate cross-origin ajax calls to jsontest.com.
Note: the only change from regular jQuery.ajax() call is the option: crossOrigin: true
<html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> <script type="text/javascript" src="js/jquery.ajax-cross-origin.min.js"></script> </head> <body> <select id="service"> <option value="http://ip.jsontest.com/">IP Address</option> <option value="http://headers.jsontest.com/">HTTP Headers</option> <option value="http://date.jsontest.com/">Date & Time</option> <option value="http://echo.jsontest.com/key/value/one/two">Echo JSON</option> <option value='http://validate.jsontest.com/?json={"key":"value"};'>Validate</option> <option value="http://code.jsontest.com/">Arbitrary JS Code</option> <option value="http://cookie.jsontest.com/">Cookie</option> <option value="http://md5.jsontest.com/?text=[text%20to%20MD5]">MD5</option> </select><br/> <input type="text" id="url" style="width: 400px"> <input type="button" id="btn" value="Get JSON"> <br/><br/> <div id="test" /> <script type="text/javascript"> $(function() { $( '#service' ).on( 'change', function(){ $( '#url' ).val( $( this ).val() ); }); $( '#url' ).val( $( '#service' ).val() ); $( '#btn' ).click(function(){ var url = $( '#url' ).val() $.ajax({ crossOrigin: true, url: url, success: function(data) { $( '#test' ).html(data); } }); }); }); </script> </body> </html>
To see the demo page in action click here