AJAX - JAVASCRIPT: A Beginner’s Guide to Learning the Basics of JavaScript Programming (2015)

JAVASCRIPT: A Beginner’s Guide to Learning the Basics of JavaScript Programming (2015)

Chapter 23. AJAX

What is AJAX? AJAX stands for Asynchronous JavaScript and XML. What does it do? Well, one of the things you can do with AJAX is to access other pages, scripts, and/or data without making your browser load another page.

Primarily, AJAX is an important component of creating dynamic content web pages. With it, you can deliver dynamic content and create rich web applications such as chat. You can perform updates on any part of your page, without forcing the whole page to reload. And those are just a few of the things you can do with AJAX.

By the way, if it XML is included in AJAX, it does not mean that you need to learn XML. With HTML knowledge and the things you have learned so far, you can take full advantage of AJAX.

How does it work? Basically, you must create an XMLHttpRequest. That request will be sent to the server. The server will process the request, and a message will be sent back to you. The reply of the server depends on the client and server scripts you created. Also, it will be up to your script to process the reply you receive.

However, despite sounding too simple, achieving rich interactions with your page and your server depends on your ability to create server scripts. Knowledge on PHP, ASP, or other server scripting language is required. Also, if you will be playing with data, knowledge in database management and SQL language will be needed.

Of course, it is possible that you are unfamiliar with how they work as of now since you are only in the beginning of your journey as a web developer (you are still learning client side scripting).

Another reason that learning AJAX will not be fruitful as of now is that you might not have proper server access. Meaning, if you do not have a web hosting account or do not have a server application in your computer or network, you can only do little with AJAX.

Nevertheless, it is still possible for you to use it, and add more functionality and flair to your web documents.

Steps in AJAX Operations

1. Client event occurrence

2. Creation of XMLHttpRequest

3. Configuration of XMLHttpRequest

4. Asynchronous Request of the XMLHttpRequest to the Webserver.

5. The Webserver will return the result, which contains the XML doc.

6. The object XMLHttpRequest will call the function callback() and the result will be processed.

7. Update of HTML DOM.