POST with JsonP
For those of you unfamiliar with JsonP, it’s the process of using script injection to fetch data across domains (where Ajax requests prevent this access). You inject a script tag into your document with the url of a web service and instruct that web service to send JSON data back wrapped in a function name you specify in the url. Then you have the function defined in your document waiting for that script to load and call your function, passing the response.
You can see it in action here using my JsonP class for MooTools.
Today I got an email from a fellow by the name of Alan who has released jsonptunnel - CGI and FastCGI scripts that receive JSONP requests (which, do to their script call methodology are always GET requests) and turn them into POST requests. Tres cool.
In order to POST to an off site web service, a GET URL is formatted and fetched that looks like this:
?extURL=http://dipert.org/alan/calc.php&extMethod=POST&num1=10….This tells the CGI to fetch the specified URL using the specified HTTP verb and pass the specified variables.
Follow @clientcide on twitter to get notified of new posts.
To follow me personally on twitter, follow @anutron.