I have a two domains, example1.com and example2.com
From example1.com, I would like call a JSON API I have on example2.com. Knowing that this is not allowed, it occurred to me - this is exactly why JSONP was created.
Question is, how do I modify my JSON API to make it JSONP capable?
Basically, how do I create the callback api?
UPDATE
My server side language is PHP
/// the callback script should return name of the Callback function, i.e. if you type in browser
http://url_to_receiver_script/index.php¶m=anything
it should return just a text (name of existing processing function): addScriptToHead(any_param)
works like a clock in any browser.
Easy with jQuery, that is the client side:
And be sure that you get proper json from the server side;
and don't forget to return the jsonp_callback param, otherwise it won't work!!!!!
and that's it really.