Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  13] [ 6]  / answers: 1 / hits: 23306  / 13 Years ago, tue, august 16, 2011, 12:00:00

I want to know that how can we get ajax status code in jquery.
I have this ajax block:



$.ajax{
type: GET,
url: keyword_mapping.html,
data:ajax=yes&sf=+status_flag,

success: callback.success,
complete: rollup_filters(),
failure: function(){
alert(Failure);
}
}


Now in above code, in case of failure, how can i get ajax status code and some description of that status code ??


More From » jquery

 Answers
2

You want to use the error option to capture this. For example:



error: function (jqXHR, textStatus, errorThrown)
// Your handler here...
}


You can then use the jqXHR object to retrieve information about the failure.



From the documentation:




For backward compatibility with XMLHttpRequest, a jqXHR object will expose the following properties and methods:




  • readyState

  • status

  • statusText

  • responseXML and/or responseText when the underlying request responded with xml and/or text, respectively

  • setRequestHeader(name, value) which departs from the standard by replacing the old value with the new one rather than concatenating the new value to the old one

  • getAllResponseHeaders()

  • getResponseHeader()

  • abort()



[#90588] Monday, August 15, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dahlias

Total Points: 730
Total Questions: 104
Total Answers: 101

Location: Denmark
Member since Tue, Jul 19, 2022
2 Years ago
;