$.ajax returns 0 as HTTP error code instead of 404
Below is my ajax call from the HTML page. Its actually a ajax call from an interation block.
In this I am expecting that a couple URLs will fail with HTTP code as 404.
From FireFox Net console i could see that the HTTP status as 404. But the jqXHR.status is 0 (zero).
Could somebody please explain why its return 0 when the actual HTTP response is 404?
- $.ajax({
- url: serviceURL,
- type: "POST",
- async: true,
- crossDomain: true,
- contentType: "text/xml",
- context: tdObject,
- dataType: "jsonp",
- origin:window.location.protocol + "//" + window.location.host,
- timeout:5000,
- success: function(data){
- //console.log("SUCCESS for ajax call ");
- httpStatusCode=data.responseCode;
- //return data.responseCode;
- },
- error:function(jqXHR, textStatus, errorThrown){
- //console.log("Error for ajax call "+jqXHR.status+"-- "+textStatus+"--"+errorThrown);
- httpStatusCode=jqXHR.status;
- //return jqXHR.status;
- }
- });