I have a code like this
var ajaxrequest = $.ajax({ type: "POST", dataType: "json", url: "xy.php", data: { action : "read" } }).fail(function(){ //something to do when ajaxreq fails }).done(function(data){ //something to do when ajaxreq is done });
He does not work. My question is why this is not working:
var ajaxrequest = $.ajax({ type: "POST", dataType: "json", url: "n3_vaje_api.php", //Relative or absolute path to response.php file data: { action : "read", }, fail:function(){ //something to do when ajaxreq fails }, done:function(data){ //something to do when ajaxreq is done } });
Failure and termination are just examples, they also don't work if they are used internally. But using it outside, like:
ajaxrequest.complete(f(){});
works just fine ... I know, instead of doing, I have to use success, but that is not my point here. What is the deal here?
source share