0

i have this ajax call to my server side is there a failed function to determine of the ajax call has failed??? i think my code only shows the success function is there some sort of code?i just need to find out if my ajax call has failed. i'm using the new syntax for ajax call i think so. any help would be much appreciated thank you.

 $.post('authorSearch',
 {FirstName:$('#FirstName').val(),limit:row},
 function (data, status, obj) {
 alert('Success');
 });

i tried to do this but its not working

   $.post('authorSearch',
     {FirstName:$('#FirstName').val(),limit:row},
     function (data, status, obj) {
     alert('Success');
     },
function(data,status,obj){
alert('failed');
});

1 Answer 1

1

You can use .done .fail .always,

$.post({
  url: "url",
  data: data,
}).done(function() { alert("success"); })
  .fail(function() { alert("error"); })
  .always(function() { alert("complete"); });

Everything is written in jquery documentation.

http://api.jquery.com/jQuery.post/ http://api.jquery.com/jQuery.ajax/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.