#1 Posted by lithin (3 posts) -


I'm in the process of developing a jQuery plugin that loads data from Giant Bomb (and does some things with them). I have come to a problem with json_callback - I can't use any function from inside of my plugin to handle the data. I am forced to use a global function but that definitely doesn't suit my needs. I could sort out the problem with using ajax's succeed but that doesn't work with Giant Bomb json_callback that must be used.

The plugin is built on a prototype model such as bootstrap functions are or this is.

It seems to me as a dead end. Is there anyone with similar experience or with experience with building such jQuery plugins? I'd really appreciated any help.



#2 Posted by Chaser324 (6743 posts) -

How are you referencing the callback function inside of your plugin?

#3 Posted by YOU_DIED (703 posts) -

Are you using the JSONP functionality in jQuery? Try $.ajax with a dataType of 'jsonp'

#4 Posted by Chaser324 (6743 posts) -
#5 Posted by YOU_DIED (703 posts) -
#6 Posted by Chaser324 (6743 posts) -

@you_died: Looks good to me. It seems like the OP should be able to piece something together, but he didn't provide much info about what he was doing that wasn't working.

#7 Edited by lithin (3 posts) -

Thanks so much for your comments!

I have written this code so far. When format: 'jsonp' is used in the data, we also have to add json_callback: 'myFunction' to it, so simply adding success to it doesn't work (let me know if I'm wrong, I'd love to be :) ). The idea with success function with a name is great, I'll try it out.

Note: My $.ajax is a part of a function of my object's prototype, "displayGames" is a function of the same prototype.

EDIT: I have tried YOU_DIED's solution and it works perfectly! Thanks so much and sorry for being so stupid. I've never worked with ajax before...