Sorry - APIResponse code not borrowed from skittr, but ESME (http:// incubator.apache.org/esme/) Thus, depending on your call's extension (.json or .xml) you can serve the response in the required format.
Anyhoo, back to the question... :-) Thanks, Juan On Oct 6, 5:48 pm, Juan M Uys <opy...@gmail.com> wrote: > Hi Lifters, > > I'm building a REST server and a separate stand-alone DHTML client > which won't necessarily be hosted on the same server. Some browsers do > not support cross site Ajax, hence JSONP (i.e. callback support). > > My DHTML client now makes calls like the following, using jQuery: > > <snip> > GET /api/version.json?callback=C&_1254838856015= HTTP/1.1 > Host: localhost:8080 > User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; > rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 > Accept: */* > Accept-Language: en-us,en;q=0.5 > Accept-Encoding: gzip,deflate > Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 > Keep-Alive: 300 > Connection: keep-alive > Cookie: JSESSIONID=13k8ykwq2u2w6 > </snip> > > I need to know if I need to build manual support in for the callback: > * grab the token 'C' > * generate a JsCmd named 'C' with my JSON response as parameter (It > will be great if someone can suggest which parts of the Lift API to > use for this) > * send it back to the client (as an extra parameter to the original > JSON, or on it's own?) > > It doesn't seem like Lift automatically picks up on "?callback=" (it's > not a standard, so - understandable), and my response looks like this: > > <snip> > HTTP/1.1 200 OK > Content-Length: 16 > Content-Type: application/json > X-Lift-Version: 1.1-SNAPSHOT > Server: Jetty(6.1.21) > > {"version": "1"} > </snip> > > The above response is generated by: > > <snip> > def version(): Box[APIResponse] = { > Full( > Right( > Map("version" -> > Map("version" -> APIHelper.getParam("api.version")) > ) > ) > ) > } > </snip> > > ...where APIResponse is borrowed from TwitterResponse (from the skittr > example). > > Another problem I have is that Firefox complains about "invalid label" > for the above response, so I think wrapping it up in a callback will > fix it. > > Here's an answer related to PHP for this > issue:http://stackoverflow.com/questions/790910/jquery-getjson-to-external-... > > Thanks, > > -- > juan > +44 7702 783 956 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---