Chapter 31. An Introduction to Ajax

Web applications are sometimes considered inferior to conventional applications—that is, applications that run natively on your chosen operating system. That mindset is easy to develop. Imagine a conventional application that has a form that users can use to input data and have it stored in a database. A host of features are common in such conventional applications, such as real-time validation, seamlessly fast response times, and real-time error reporting.

Compare all that to a comparable web application. Users input data into the form and submit it. There is some real-time validation that you can do with JavaScript, but often with such web applications the server is responsible for comprehensive validation. The experience is disjointed when users click the form's submit button: The page has to reload with new data from the server, so not only does the page flicker, but it has to be downloaded again. If an error occurs, users don't know it until the page is completely loaded in the browser.

There are a variety of factors that contribute to the differences between conventional and web applications, but perhaps the largest hurdle web developers face is the HyperText Transfer Protocol (HTTP). The Internet relies upon several components in order to function, and probably the most important component is HTTP, a request-response protocol. When you open a browser and go to any website, your browser sends an HTTP request to the website's server to retrieve ...

Get JavaScript® 24-Hour Trainer 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.