This is how I use $.ajax
var link = "http://www.myapp.net/..."
$.ajax({
url: link,
cache: false,
async: false,
success: function(html){
},
error: function(){
}
});
The result of the request is either an empty page or a page with just a number. So error callback actually should never be triggered, as long as the request does not fail.
But I always get the following error
alert(jqXHR + "-" + textStatus + "-" + errorThrown);

Here is some information about the error code in the picture
I run my project on localhost. The link in the ajax code points to another project on the web.
Any ideas?
The error callback is executed if the ajax call can't be completed - i.e. if the url is on a different domain (or if you are running it from a local file), if the request timeouts, or if the server responds with an error code.
I'm guessing it's a domain (same-origin) policy error
Update: If you want to do cross-domain Ajax, check out James Padolsey's jQuery snippet for just that (uses Yahoo!s public proxy to make all jQuery Ajax calls cross-domain)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With