Below is my code
var tweetid = '133450847156838400';
$.ajax({
dataType: "jsonp",
url: "http://api.twitter.com/1/statuses/show/"+tweetid+".json?include_entities=1&callback=?",
error:function(xhr, testStatus, error) {
alert("error");
},
success: function(html){
alert("success");
}
});
Chrome console shows me 404 error response but jQuery is not able to trigger the alert.
I added
$(document).ajaxError(function(event, request, settings){
alert('error');
});
nothing happens. Can someone help me in handling this error as I have to detect if this tweet is deleted.
I’m pretty sure (not entirely), that the dataType jsonp doesn’t properly handle non-200 http status codes. The reason is on jsonp actually works. The wikipedia page explains it better: http://en.wikipedia.org/wiki/JSONP, but basically, jsonp amounts to appending a script element onto the page with the url you’ve given. And the body of the script element is a function call. If you get any status code != to 200, then that body will not be there and no function will be called (which eventually calls the callback functions).
So, if you continue to use jsonp, then you will need to have some kind of timeout in waiting for a response and expect that the request failed or some other method.