jQuery.ajax fails when url is from different server

Its because of the restriction on cross domain requests implemented in the browser for XMLHttpRequests. You can get around this by using JSONP as the format, otherwise you’ll need a server-side proxy for the request.

Quoting from the ajax documentation on http://jquery.com

Note: All remote (not on the same
domain) requests should be specified
as GET when ‘script’ or ‘jsonp’ is the
dataType (because it loads script
using a DOM script tag). Ajax options
that require an XMLHttpRequest object
are not available for these requests.
The complete and success functions are
called on completion, but do not
receive an XHR object; the beforeSend
and dataFilter functions are not
called.

Leave a Comment