My question is specific to oodle API.
I am trying to call oodle API to get the JSON result like this:
$.getJSON("http://api.oodle.com/api/v2/listings?key=TEST®ion=sf&category=sale&format=json&mappable=address&jsoncallback=none", function (data) {
alert(data);
}开发者_运维百科
You cannot make cross domain request (XSS). You will need to use JSONP by changing the jsoncallback parameter from your request to jsoncallback=?
instead of none. The latest version of jquery will then handle JSONP correctly.
The Oodle API specs mentions jsoncallback: http://developer.oodle.com/listings
$.getJSON("http://api.oodle.com/api/v2/listings?key=TEST®ion=sf&category=sale&format=json&mappable=address&jsoncallback=?", function (data) {
alert(data);
});
This uses JSONP. The ? tells jQuery where to insert the name of the callback. You had none, which is incorrect. Also, you were missing a right paren.
精彩评论