I like to work with the very basics and be able to use some of the new stuff that is out there like the jQueryUI components etc, and to customize them enough to be specific to my exact needs. To do that I had to go though all the details of how lift does ajax and json calls. So lets start:

first thing the jquery ajax call:

http://api.jquery.com/jQuery.ajax/

here the basic definition of the ajax function is as follows:

https://gist.github.com/1729878

This is essentially what you want to do in most cases, say bind it to a javascript callback function that updates the ui or a variable.

Problem: what url to use, and where to put the success funtion? lets have a look.

Lifts has a way to make ajax calls a lot more secure and even bind it to a callback function specific even to an object. This is very nice functionality since it allows you to send minimum information to the client and keep most of the state on the server.

The basic idea is that all ajax handlers are maintained in a Map[String, AFuncHolder]. Whenever you create a lift ajax call you get back a (String, JsExp). The String part is key in the map to access the callback function. JsExp is the javascript you need to call this function from the clientsite, think of it as your jQuery url. So lets see a basic example: a jquery button

first the html template:

https://gist.github.com/1730616

The lift snippet with enough comments:

https://gist.github.com/1730594

Essentially the result of the callback function is the success funtion.

The aCall._2.toJsCmd will give you an alternative to the URL of the jQuery ajax function, that is more secure and used wisely will give you so much more that.