6.2. JavaScript and Ajax

Hiding and displaying the forms alongside the action icons is something that can be accomplished with basic JavaScript and will certainly be discussed later in this chapter. However, more complex scripting is needed for the file listing to reflect the state of the remote directory without requiring a full page reload. For this you must have a basic understanding of Ajax.

Not too many years ago a developer used to be able to get by with just knowing HTML. Then forms and CGI came about, followed by JavaScript and CSS. The simple days are long gone; now web sites are offering the same functionality that used to be the exclusive domain of desktop applications. You need to know a whole slew of different technologies and languages just to be even a moderately capable web developer.

A new buzzword, Ajax (which stands for Asynchronous JavaScript And XML), has surfaced in the past few years referring to the use of JavaScript to dynamically update a page's contents. Many web applications use JavaScript in this manner to improve functionality and add special eye-candy effects. It's not really a new concept, however; in fact developers who have been around a while may know it by another name — DHTML (Dynamic HTML).

The basic underpinning of the Ajax paradigm is the ability to make an HTTP request behind the scenes while a visitor is viewing a page. The web server responds with a message that JavaScript then parses and uses to update the page by replacing content, ...

Get PHP and MySQL®: Create-Modify-Reuse now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.