Reputation: 489
I am trying to retrieve the source code of an IMDB page using jQuery and jsnop, using the following code:
$(document).ready(function (){
var url = "http://www.imdb.com";
var success = function(data){
// work
};
$.ajax({
type: 'GET',
url: url,
data:{todo:"jsonp"},
dataType: "jsonp",
crossDomain: true,
cache:false,
success: success,
error:function(jqXHR, textStatus, errorThrown){
console.log(errorThrown);
console.log(textStatus);
}
});
});
I am getting following errors:
object error
parse error
Upvotes: 2
Views: 147
Reputation: 111
Actually the problem is the format, as your are hitting http://www.imdb.com which will return html which is basically a xml format, but your ajax call expecting a JSON format, try yahoo ypl
//like this
var site = 'http://www.imdb.com';
var encoderUrl = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from xml where url="' + site + '"') + '&format=xml&callback=?';
$.getJSON(encoderUrl, function(data){
console.log(data);
});
Upvotes: 2