How JSONP works
There are a plethora of explanations for JSONP (JSON with Padding, I think it stands for) out there – just search for “how JSONP works” and you’ll get a ton of descriptions. JSONP is provided as an alternative to normal JSON by jQuery on the client side to enable the invocation of services outside of the current domain.
Some of them are incorrect in explaining that this technology uses a server-server proxy to call out to another server outside of the current domain.
This is NOT a server-server technology, but rather more like the way a lot of Ad servers by injection javascript into the page using document.write() with a script tag.
The url for the script tag has a querystring parameter which become that javascript function that wraps up the JSON return value of the web method. Essentially, a document.write() call creates a script tag on the page which goes to whatever server you want to, and then returns a javascript function object which will get invoked when the script’s response is evaluated by the browser. This means that the server code has to be tweaked to wrap the JSON return in that function call.
One thing you will not get from JSONP is notification of network errors or anything that responds nicely to badly formed responses, so you have to accept that as a tradeoff with the ability to invoke services on other domains.
This is a very high level explanation of JSON, but I hope it gets you started in right direction.
More later - joel