2

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.

2 Answers 2

4

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");
  },
});
Sign up to request clarification or add additional context in comments.

2 Comments

Doesn't seem to work. I'm still getting "processLeaderboard is not defined".
Use jsonpCallback: 'processLeaderboard' instead of jsonp: 'processLeaderboard'
3

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=?'

   });
});​

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.