Reputation: 951
I'm having the following problem:
I am grabbing tweets from twitter, using their API. Whenever I've hit the limit of requests, it is returning me a 400 (Bad request) - reply.
Now, how can I find out whether a 400-reply was returned? The callback 'Error' isn't triggered.
$.ajax({
url: 'http://api.twitter.com/1/statuses/user_timeline/' + Followed[Index] + '.json?count=' + Tweetlimit + '&include_rts=true',
dataType: 'jsonp',
success: function (json) {
$.each(json, function (index, tweet) {
var date = Date.parse(tweet.created_at);
Tweets.created_at = date.toString('hh.mm.ss - dd/MM/yy');
Tweets.created_as_date = date;
Tweets.push(tweet);
})
CompletedUsers = CompletedUsers + 1;
},
error: function () {
alert("Error");
},
});
Upvotes: 0
Views: 95
Reputation: 3360
success
is called when request succeeds. error
is called when request fails. So, in your case, request succeeded and success
is called. Now, if you want to respond to specific codes, you should follow this example in addition to your code:
$.ajax({
statusCode: {
404: function() {
alert("page not found");
}
}
});
Upvotes: 3