It looks like jQuery's .ajax
function fires the 'success'
function even when it gets no response from the server. I'd consider this an error. I detected this event by checking to see if the 'request.status===0'
, are there any other instances that I should check for where the 'success'
function will be fired even if there is an error situation?
I've posted the code I'm using now below. How is this type of situation normally handled?
$.ajax({
async : true, cache : false, dataType : 'json',
type : 'POST',
url : 'person/' + personKey,
data : JSON.stringify({firstName:'Jilopi',}),
success : function(data, textStatus, request){
if( request.status === 0 ){
alert('Error: problem saving person - no response');
}else{
alert('Success: saved person');
}
},
error : function(request, textStatus, errorThrown){
alert('Error: problem saving person');
},
});