Making the Requests

We now understand how to bridge the gap between the front end and the database; now we need to focus on how to make the XHR from the front side. Making the connection to the connector file we created in the last section is as easy as requesting static XML files. It is really just a matter of understanding what parameters to pass it and how it will return that data so you can anticipate dynamic responses. Listing 20.3 shows how to make an XHR from our Email JavaScript object on the client side to our serviceConnector.php file.

Listing 20.3. Connecting to the Database to Retrieve a User’s Email Folders (Email.js)
Email.display = function(username) { Email.currentUser = username; var url = "serviceConnector.php?object=Email&method=getFolders&params="+ ...

Get Ajax for Web Application Developers now with O’Reilly online learning.

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