I\'m developing an application for Netflix using their OData API. I\'ve followed Stephen Walther\'s blog entry on how to query the OData API. In it, he uses the following co
Don't define callback, because jQuery creates that function for you. Here's an example, jsFiddle:
function getTitles() {
query = "http://odata.netflix.com/v2/Catalog" // netflix odata base url
+ "/Genres('Television')" // select Genre
+ "/Titles" // top-level resource
+ "?$select=NetflixApiId,Name,BoxArt,Synopsis,ReleaseYear,AverageRating,Series" // choose fields
+ "&$orderby=Name" // Sort results by name
+ "&$filter=Instant/Available eq true" // filter by instant view
+ " and Type eq 'Season'" // select only seasons
+ "&$expand=Series" // include series data
+ "&$callback=?" // specify name of callback function
+ "&$format=json"; // json request
$.ajax({
dataType: "jsonp",
url: query,
success: callback,
error: function(XHR, textStatus, errorThrown){
alert(textStatus + ":" + errorThrown);
}
});
}
callback=? basically asks jQuery to handle all the JSONP returns.