[jQuery] Remote JSON Ajax call - error function not called
Hi,
I am trying to retrieve JSON Data from a remote server and manipulate
teh returned data. That all works fine - the callback is executed and
it all works as expected. The issue I am running into is that I want
to use timeouts and error messages also - and they are not working.
I tried the following code (just demo code - not the one I am using)
$.ajax({
type:"GET",
url: "http://www.thisSite.com/badurl.asp",
data:"jsoncallback=?",
dataType: "json",
timeout: 1000,
error: function(){
alert('Error loading document');
},
success: function(data){
alert(data);
}
});
If I run the above function I would expect the error function to be
called as it would get a 404 error for the bad URL... but that *does
not happen*. No function is called. If, however, you change the URL
to be a local address (but still incorrect) then the error function
*is* called.
I'm sure I'm missing something fundamental!! But is there a way to
call error functions for remote urls? And if so how!
Thanks,
Patrick