xmlhttprequest - Make my jQuery Ajax script use CORS -


i built application reads data via ajax external website. works fine found out in question if want package blackberry 7, webworks or phonegap, may need use called cors.

how can convert following script same thing except using 'cors'?

    <script type="text/javascript">         $("#page_all").live('pagebeforecreate', function() {         $.get('http://mysite.com/mobile/data/data_all.php',function(data){             $('.content').empty();             $(data).find('market').each(function(){                 var $market = $(this);                 var html = '<div class="data">';                                       html += '<div data-role="collapsible" data-collapsed="true" data-theme="b"><h3>' + $market.attr('date') + '</h3>';                 html += '</div>';                 $('#result').append(html).trigger( "create" );                 $('#result .loading').remove();             });                                 });         });     </script> 

you hitting domain (ontariosheep.org) other domain name, , brings cross-domain poll.

cors way solve this, , has server hosts data_all.php needs set have in response header property:

access-control-allow-origin: * 

or, can use other common method called jsonp.

using jsonp method, call should like:

var url = "http://ontariosheep.org/mobile/data/data_all.php"; $.get(url + "?callback=?", function(data) {     // method body      }); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -