Chapter 9.1. Handling Ajax Requests

The first thing to think about when dealing with Ajax is the way the browser and server communicate. From the server side, everything still comes in as an HTTP request and gets passed to the first object to match in the CherryPy controller hierarchy. So, the first thing you generally want to do is set up a controller method that handles an HTTP request and returns the data you eventually want your JavaScript to see.

In general, you will return one of three things to the browser: HTML, XML, or JSON.

Get Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.