Can someone see why this JQuery JSONP is not working?
$.getJSON("https://api.foursquare.com/v2/venues/search?&callback=fs_venue_search", {
ll: "40.7,-74",
client_id: "Y3AWKSPSCWEGGSQBELQVDWRG4EX4PRWJ4HMWSKGQSVRPPXI1",
client_secret: "abc",
开发者_运维百科 format: "json"
}, function(data){
alert(data);
});
Nothing happens when I run this script.
This one
$.getJSON("https://api.foursquare.com/v2/venues/search?&callback=?", {
ll: "40.7,-74",
client_id: "Y3AWKSPSCWEGGSQBELQVDWRG4EX4PRWJ4HMWSKGQSVRPPXI1",
client_secret: "5FBPDNM2TQDMFSBQUKZSWR3ZGJWDTXYA2IHJLLMMO0J2LVC",
format: "json"
}, function(data){
alert(data.meta.code);
});
work and display "200".
You're providing callback=
in the original URL and in the data object. One of them appears to be misspelt. Set only one, and see if your code then works.
Solved.
$.getJSON("https://api.foursquare.com/v2/venues/search", {
ll: "40.7,-74",
client_id: "Y3AWKSPSCWEGGSQBELQVDWRG4EX4PRWJ4HMWSKGQSVRPPXI1",
client_secret: "abc",
format: "jsonp"
}, function(data){
alert(data);
});
精彩评论