tags:

views:

164

answers:

2

Hello,

I'm trying to get data from another domain using jQuery. Here is the code:

$.ajax({
    type: "GET",
    dataType: "script",
    url: "http://www.example.com/ajax.php",
    data: 'id=5',
    success: function(msg){
     console.log(msg);
    }
}

Now, in Firebug's console instead of the result I get error "overlarge sharp variable number"?! How I can fix this? The ajax.php print timestamps imploded with "|", eq 1245925436|1256335200|1245925436...

+1  A: 

You cant do x-domain ajax calls successfully cross browser. You either need to use a server side proxy at your end or use json-p if the calling end supports it.

redsquare
A: 

You can't to cross domain ajax calls due to security concerns. You can however setup a server side page to act as a proxy. For an example, see http://www.daniweb.com/code/snippet494.html (PHP) or http://dotnetslackers.com/columns/ajax/MashitUpwithASPNETAJAX.aspx (ASP.net)

Also see http://jasonkelly.net/archive/2009/02/24/using-jquery-amp-jsonp-for-cross-domain-ajax-with-wcf-services.aspx and http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/ for an example on accomplishing this with JSON-P but note that this relies on cooperation from the other server.

Jonathan Fingland