Note: This was written against beta 1 of the JQuery Templates, things most likely will change and this code might need to be modified to continue working in future releases.
The PHP page is very easy and simply writes back some JSON.
File name: callajax.php
'Apple', 'mobileDevice' => 'iPad2'), array('manufacturer' => 'Motorola', 'mobileDevice' => 'Xoom'), array('manufacturer' => 'Samsung', 'mobileDevice' => 'Galaxy Tab'))); ?>
The HTML markup I’m going to use will look like this:
This will get rendered into this unordered list:
When the Ajax is triggered it calls the PHP page and the onSuccess function is called to render the template to the browser:
The full code listing for the index.html page looks like this:
Here are the results: