When I bring my server down and make an ajax request to it, firebug shows that the request is aborted a few seconds after making the request, and my success
handler gets called.
Why does the success handler get called, shouldn't it be the error handler? And how can I reliably detect that it wasn't actually a success?
CODE:
$.ajax({
url: url,
type: "POST",
data: data,
dataType: "json",
success:function(data, statusText, xhr){
//gets called on success, or even when server is down.
},
error: function(){
//called if server returns error, but not if it doesn't respond
}
});
UPDATE: This behavior is only on localhost, it happens when turning off my development server. I tested to see what happens when I try to reach the production server, but have my personal internet taken offline, and it just hangs, not calling success or error at all. Guess I should set the timeout property for that case.