Giant Bomb jQuery plugin

Avatar image for lithin
lithin

5

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

Hi,

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.

Thanks,

Lithin

Avatar image for chaser324
chaser324

9416

Forum Posts

14945

Wiki Points

0

Followers

Reviews: 1

User Lists: 15

#2 chaser324  Moderator

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

Avatar image for you_died
YOU_DIED

711

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

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

Avatar image for chaser324
chaser324

9416

Forum Posts

14945

Wiki Points

0

Followers

Reviews: 1

User Lists: 15

#4 chaser324  Moderator
Avatar image for you_died
YOU_DIED

711

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

Avatar image for chaser324
chaser324

9416

Forum Posts

14945

Wiki Points

0

Followers

Reviews: 1

User Lists: 15

#6 chaser324  Moderator

@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.

Avatar image for lithin
lithin

5

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#7  Edited By lithin

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...