The jQuery function seems to .ajaxrun the function 'success', even if it does not receive a response from the server. I consider this a mistake. I detected this event by checking if there are 'request.status===0', are there any other instances that I have to check where the function 'success'will run, even if there is an error?
I published the code that I am using below. How is this type of situation usually 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');
},
});
source
share