开发者

JQuery call to oodle API returns nothing?

开发者 https://www.devze.com 2023-01-07 03:21 出处:网络
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&region=sf&category=sale&fo

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&region=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&region=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.

0

精彩评论

暂无评论...
验证码 换一张
取 消