Ajax Request Failing, print out error message but how?
Hi,
I use the "getJson" Ajax function in jquery calling a specific url and get the response format in json.
As you see if the Request starts it displays a loading logo and after the request is finished the logo is hidden again.
BUT if the request fails (no response from the called url) I´m screwed, the function you see below ("setTimeout("if ($('#loadinglogo').show() == true){ error(); }", 10000);") doesn´t solve the problem because I run into sync problems that way.
Is there an easy way to acomplish what I want? (meaning if the url not responds print out an error message specified in my error() fct.)
-
$('#loadinglogo').ajaxStart(function() {
$(this).show();
//If Ajax fails
setTimeout("if ($('#loadinglogo').show() == true){ error(); }", 10000);
}).ajaxStop(function() {
$(this).hide();
});
//Direkter Json Request an Solr (ohne Umweg)
$.getJSON("http://localhost/select?q=" + $("#anfrage").val() + "&wt=json&json.wrf=?&jsoncallback=?",
function(data){................
kind regards,
Sebastian