I have the following bog standard jQuery ajax request. I've been trying to induce an error state by disconnecting my computer from the network mid-request (the server takes 10 seconds to reply so this is simple).
When I disconnect alert('Success: '+ json);
is called, with null
for the response json. I would expect the error part to be called.
Anyone know why the disconnect is being treated as a success, and how instead to induce a fail?
$.ajax({
url : 'post.php',
data : { id : 123 },
type: 'POST',
dataType : 'json',
success : function(json) {
alert('Success: '+ json);
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
alert('Error: ' + errorThrown);
},
complete : function(xhr, status) {
}
});