Chapter 14. Moving Outside the Page with Ajax

Ajax originally encompassed functionality that allowed in-page communication between the client page and the server. Its meaning has now grown to also include most dynamic web page effects, including those that used to be labeled Dynamic HTML (DHTML). More than any previous innovation, Ajax has led to a greater interest in JavaScript in general and dynamic JavaScript functionality in particular.

The Ajax examples in this chapter differ from examples in previous chapters in that Ajax requires a server component. Ruby is a popular choice of programming language for Ajax development, but any server-side language that can process the specialized Ajax requests will work. The examples in this chapter use PHP, primarily because out of all the languages it’s the most similar to JavaScript, and because it’s one of the most common server-side scripting languages in use.

Note

Technically, you don’t need to use a server-side language to support an Ajax application; you just need the response to be served from a server. So, you could instead use a library of static HTML or XML files on the server that are returned based on the Uniform Resource Identifier (URI) of the request. However, a server-side application processing a request and formulating a response is the common type of Ajax application, and the one I’ll be demonstrating in this chapter and the next.

How Ajax Works

Ajax is not as complicated as it may seem at first. A request needs ...

Get Learning JavaScript, 2nd Edition 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.