I would like to make a little Pico Lisp HTTP server that can handle XMLHttpRequests from jQuery.getJSON(...), and I wonder if I can use lib/http.l. If you don't know jQuery.getJSON, you can find some info and a nice little demo here: <http://docs.jquery.com/Ajax/jQuery.getJSON#urldatacallback>

The surprising thing about jQuery.getJSON is that "you can load JSON data located on another domain". I don't know the technical explanation for this "domain freedom", but it works.

What the server has to do, is to look for certain form value keys in the request, the most important being the "callback" key. When you set up the getJSON call in JavaScript, the callback parameter is a JavaScript function, but when the server receives the request, the value of the callback key is typically something like "jsonp1210935682031". The server must then (e.g. depending on other form values) calculate some values to return and pack them in JSON format, wrapped in the value of the callback key. If the value to be returned is {d:16, m:5, y:2008}, and the value of the callback key was the one above, then the content of the response should be "jsonp1210935682031({d:16, m:5, y:2008});".

With these things we could make lots of nice Pico Lisp front ends. ;-)


Reply via email to