Hi, I am confuse of this jquery.ajax,how can i alert this three parameters if the request get fails, i want to know what the error causes and to alert this error.like errorparsing,error, pagenotfound..etc...

by reading this

errorType: Function( jqXHR jqXHR, String textStatus, String errorThrown )A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror". When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." As of jQuery 1.5, the error setting can accept an array of functions. Each function will be called in turn. Note: This handler is not called for cross-domain script and JSONP requests. This is an Ajax Event.

Hi, I am confuse of this jquery.ajax,how can i alert this three parameters if the request get fails, i want to know what the error causes and to alert this error.

It is the errorThrown variable that contains info about what caused the error.

jemz
—
2013-03-22T10:12:51Z —
#3

paul_wilkins said:

It is the errorThrown variable that contains info about what caused the error.

Hi paul, thank you for the reply what about the parse error do i need to delclare each of them like this $.ajax({ type: 'post', url: 'notfoundpage.php', error: function(jqXHR,textStatus,errorThrown ){

alert(errorThrown);

}, error: function(jqXHR,textStatus,errorThrown ){

alert(jqXHR);

}, error: function(jqXHR,textStatus,errorThrown ){

alert(textStatus);

}, ..... .....});

please enligthen my mind..

Thank you in advance

Paul_Wilkins
—
2013-03-22T10:15:53Z —
#4

jemz said:

Hi paul, thank you for the reply what about the parse error

The parse error is not a problem with that error function.

Instead, the "parse error" is the error message about why the ajax request is failing. Because 'notfoundpage.php' is not a valid URL.

jemz
—
2013-03-22T10:43:34Z —
#5

paul_wilkins said:

The parse error is not a problem with that error function.

Instead, the "parse error" is the error message about why the ajax request is failing. Because 'notfoundpage.php' is not a valid URL.

yes, I tried the parse error message by using the textStatus, I tried to make the url as invalid so that it will alert "page not found",but if i will just alert the textStatus it will not display the page not found, my point is how can i know or to alert message error that causes my ajax request to fail..

Thank you in advance.

Paul_Wilkins
—
2013-03-22T11:01:49Z —
#6

jemz said:

it will not display the page not found, my point is how can i know or to alert message error that causes my ajax request to fail..

The ajax request didn't even get started, so errorThrown will not have anything to show.

(from the jQuery page):

When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error."

jemz
—
2013-03-22T11:12:17Z —
#7

paul_wilkins said:

The ajax request didn't even get started, so errorThrown will not have anything to show.

(from the jQuery page):

When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error."

Hi paul, And how can i show such as "Not Found" or "Internal Server Error." ?

Paul_Wilkins
—
2013-03-22T11:16:09Z —
#8

jemz said:

Hi paul, And how can i show such as "Not Found" or "Internal Server Error." ?

Aha - the information about that will be in the status property of the jqXHR object

jemz
—
2013-03-22T11:55:02Z —
#9

paul_wilkins said:

Aha - the information about that will be in the status property of the jqXHR object