I found about JQuery jsonp issues in jQuery ajax (jsonp) ignores a timeout and doesn’t fire the error event.
I have tried to get my last twitter updates with:
var jsonTwitterFeed = "http://twitter.com/statuses/user_timeline/softamo.json?count=3";
$.jsonp({
url: jsonTwitterFeed,
data: {},
dataType: "jsonp",
callbackParameter: "jsoncallback",
timeout: 5000,
success: function(data){
$.each(data, function(){
$("#sNews ul.tweets").append("<li>" + replaceURLWithHTMLLinks(data.text) + "</li>");
});
},
error: function(XHR, textStatus, errorThrown){
alert("ERREUR: " + textStatus);
alert("ERREUR: " + errorThrown);
}
});
function replaceURLWithHTMLLinks(text) {
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
return text.replace(exp,"<a href='$1'>$1</a>");
}
The error alert calls execute with:
ERREUR: error
ERREUR: undefined
However, I can see the JSON Object in Firebug.
Any idea what's happening?