Table of contents
Historically, Web applications have functioned in the following manner:
- A Web browser requests an entire page from a Web server.
- A user clicks a link or submits a form, causing the browser to send a new request to the server.
- The Web server responds by sending another complete page to the browser.
By using AJAX, when a user triggers an event on a page, the browser sends a request to the Web server. Rather than load a completely new page, the currently loaded page is updated with new information. This results in a much smoother experience for the user, more like that of traditional desktop applications than the page-based model of the Web.
The request the browser sends to the server will be returned in XML, text or JSON format. Which format you choose is dictated more by your skills and needs then anything else. XML will require parsing to get to the values and is used for data where the format is unknown. Text is great for just replacing html content on the form. JSON is for passing data with a known structure.