5. adding records via Ajax

In the previous chapter, we created a way to add employees to the database. That process required one HTML form and one PHP script that handled the form. It all works fine but in the old-fashioned, client-server kind of way.

In this chapter, let’s set an Ajax layer on top of those scripts so that, for the browsers that support it, our form for adding employees can behave more like a desktop application. To do so, we’ll need to slightly modify the HTML page. Then we’ll create one JavaScript file that has the page-specific Ajax functionality. Finally, a new PHP script will be written that handles the Ajax request.

This example will also introduce two new techniques: sending an Ajax request using the POST method and

Get Building a Web Site with Ajax: Visual QuickProject Guide now with O’Reilly online learning.

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