After I managed to do an ajax call the next thing that I need to try is Json. For this example I will try to emulate the jQueryUI autocomplete component with remote Jsonp datasource, you can find the jQuery example here:

http://jqueryui.com/demos/autocomplete/#remote-jsonp

This example is particularly usufull if you have very large datasets where you don't want to send all the data to the client. Try to send all the 8000 elements to your javascript things will be pretty unresponsive. Json is also more efficient and works with most modern Javascript frameworks, also you avoid html rendering/redrawing and simply update the json source for various components. The code we want to port to a lift snippet is summarized here:

https://gist.github.com/1747029

As you can see there's already a jquery ajax call here, like the one discriped in a previous post. Here we have a few more options so lets see how this will work with lift.

The main idea that I tried to implement is json messages between my javascript code and the snippet code (I guess something like actor programming). I love the way Lift takes away all the parsing/serializing and leaves the code so clean and compact. The only thing that I didnt manage to do properly is return a Json object from my snippet. I had to do some hacking there but I think everything else is very straight forward.

The Html:

https://gist.github.com/1766968

The Snippet code:

https://gist.github.com/1766971