The only thing needs to be done is to wrap the JSON output with the requested parameter in URL's query ( as text, nothing else )
Lets say that for a certain query, this is the JSON output from *FanArt*'s site:
Code: Select all
{ "artist": "bla", "background": "http://..." }
And I wrote on my site's JS file ( js/some.js ) the following:
Code: Select all
function my_fanart(json_output) {
.... doing something with json_output from FanArt's site ....
}
function artist_background(json_output) {
.... doing something with json_output from FanArt's site ....
}
Example 1
Code: Select all
# I requested http://api.fanart.com?some_functions¶ms......&callback=my_fanart
# output should be:
my_fanart({ "artist": "bla", "background": "http://..." })
This will execute my website's JS function "my_fanart"
Example 2
Code: Select all
# I requested http://api.fanart.com?some_functions¶ms......&callback=artist_background
# output should be:
artist_background({ "artist": "bla", "background": "http://..." })
This will execute my website's JS function "artist_background"
Example 3
Code: Select all
# I requested http://...... ( w/o any callback parameter )
# output should be as today:
{ "artist": "bla", "background": "http://..." }
Will not execute anything - and this is how it's currently working
"callback" is just a URL query parameter with a value "my_fanart" or "artist_backgroun", so on the backend - you take the "callback"'s param value, and output it in the format of:
Code: Select all
callback_value(and your JSON output)
Hope it's clearer,
Ricky.