Reputation: 13347
I have the following function in a jQueryMobile page running in chrome and firefox. This same function runs without error in a PhoneGap + jQueryMobile app in iOS Simulator, but for some reason when it's run in the browser the error function gets called.
textStatus
returns null
and errorThrown
returns "error"
$.ajax({type : "GET",
url : "https://itunes.apple.com/lookup?id=356541460&entity=album",
data : {get_param : "results"},
dataType : "json",
error : function(jqXHR, textStatus, errorThrown) {alert(errorThrown); alert(textStatus);},
success : function(data) {
$.each(data, function(index, element) {
$.each(this, function(index, element) {
if (element.wrapperType === "collection") {
$("#albums-list").append("<li><a id='albums-a-" + element.collectionId + "' href='#album-details'><img src='" + element.artworkUrl100 + "' />" + element.collectionName + "</a></li>");
$("#albums-a-" + element.collectionId).bind('click', function(index) {
Albums.AlbumID = element.collectionId;
});
}
});
});
$("#albums-list").listview("refresh");
}
});
Could this be a bug? Is this not designed to run in a browser?
Is there another function that I could use that would not have this result?
Upvotes: 1
Views: 847
Reputation: 191749
If this is a cross domain request (likely), you need to add a callback for jsonp to the URL:
url : "https://itunes.apple.com/lookup?id=356541460&entity=album&callback=?",
Upvotes: 2