Reputation: 57
So, here's my JSONP URL:
http://community.tradeking.com/leaderboard.js
And here's the jQuery I'm trying to parse it with:
$.ajax({
dataType: 'jsonp',
jsonp: 'callback',
url: 'http://community.tradeking.com/leaderboard.js?callback=?',
success: function () {
alert("something");
},
});
And here's the error I'm getting in Firebug:
processLeaderboard is not defined
I've also tried getJSON and the jQuery JSONP specific plugin, but they all fail in similar ways. The JSONP is being used successfully elsewhere.
Upvotes: 2
Views: 4439
Reputation: 45731
You need a function that is called processLeaderboard
, since that function name seems hardcoded into the response from your link.
var processLeaderboard = function (data) {
alert('Do your stuff here');
}
$.ajax({
dataType: 'jsonp',
jsonpCallback: 'processLeaderboard',
url: 'http://community.tradeking.com/leaderboard.js?callback=?',
success: function () {
alert("something");
},
});
Upvotes: 4
Reputation: 70538
This worked just fine for me in jsbin using chrome.
var processLeaderboard = function(x) {
alert(x[0].member.avatar.public_filename);
};
$(document).ready(function() {
$.ajax({
dataType: 'jsonp',
jsonp: 'processLeaderboard',
url: 'http://community.tradeking.com/leaderboard.js?callback=?'
});
});
Upvotes: 3