Error while displaying $ .post using $ .ajaxError
I would like to catch the ERR_EMPTY_RESPONSE error when I do $. post .
My jquery code $ .post:
$.post( "parseRequest", { request: "myFile.xml" }, function( data ) {
//do something with json data
}, "json");
Sometimes, if the file does not exist, for example, the server sends an empty response. I will get this on the client side:
POST http://localhost:8081/parseRequest net::ERR_EMPTY_RESPONSE
Is there a way to catch this?
I tried using .ajaxError () but I am not using it correctly ... this is what I tried:
$.post( "parseRequest", { request: "myFile.xml" }, function( data ) {
//do something with json data
}, "json").ajaxError(function() {
console.log( "** Triggered ajaxError handler." );
});
But I am getting 'function undefined' error when I try to do this.
I am using jquery 1.11.1
Relevant pages:
- $. post: http://api.jquery.com/jquery.post/
- $. ajaxError: http://api.jquery.com/ajaxError/
Any help? Thank!
+3
source to share
No one has answered this question yet
Check out similar questions: