Ajax Basics

Ajax is an acronym which stands for Asynchronous JavaScript and XML. It is the method of using the XMLHttpRequest object to facilitate communication with scripts that are server sided. It can send data in a variety of different formats, and it can receive data as well. Some of the formats which make up Ajax include HTML, XML, and basic text files. One of the most powerful features of Ajax is its ability to be "asynchronous,"and this means it can carry out functions without having to refresh a page. This means that various elements within a page can be updated based on the actions of the user, and the waiting time has been dramatically reduced.

In addition to being able to make a request from a server without having to reload a page, Ajax can also handle XML documents and parse. It is these features which make Ajax so powerful, and ever since the introduction of the concept by Jesse James Garret, Ajax has been all the rage among web developers. All the signs indicate that Ajax will be responsible for changing the web in a way that Flash is not capable of doing. While many simply have dismissed Ajax as being a temporary fad, one that will die out like all the other online fads, it has become clear that Ajax doesnt fall under this category.

Making a Request With HTTP

If you wish to make a request to a server with JavaScript, it is important for you to have an instance of a class that will give you this function. This type of class was introduced with Internet Explorer in the form of an object, and this object was known as XMLHTTP. After a while, other companies begin to realize the usefulness of the object, and they added it to their own browsers. Some of these companies included Apple, Mozilla, and Opera. They used an XMLHttpRequest that has the same properties of the object introduced by Microsoft.

If you are working with a Mozilla browser, it may not work properly if the response back from the server does not use a XML mime header. To deal with this issue, you will need an additional method request to override the data that was sent out by theserver, and this is done in the event that it is not text or XML. Once you receive a positive response from the server for your request, you will next need to use the HTTP object in a way that allows it to process a response. The best way to do this is to use the onreadystatechange propery.


Making a Request With HTTP Continued

There should be no brackets once the function name has been processed, and the reason for this is because you will be assigning a reference for this function. In addition to this, instead of providing a name for the function, you will need to use theJavaScript technique to define a certain number of functions as you work. These functions will be referred to as being anonymous. You will also need to define the actions that will be responsible for facilitating the response. This should allow you to declare what will occur once the response has been received.

Now that you have done this, the next thing you will need to do is make a request. This can be done by making a call with the open () as well as the send () methods. These methods are directly connected to the HTTP request class. The very first parameter connected to the open () should be the HTTP request method. As expected, you will want to use a method that is fully supported by your browser.The method will need to be capitalized just as defined within the standard for HTTP. If you dont do this, some browsers like Firefox may not be capable of processing the request.

Sandeep Joshi
Mathematics, Technology and Programming are my passion. I am a part of Java Ecosystem and through this blog, I contribute to it. I am here to blog about my interests, views and experiences.
I am on Google+ and Facebook.
I feel proud to be listed as a "National Memory Record Holder" in the Limca Book of Records, 2009 and have attempted for an International Memory record in the Guiness Book of Records. I can remember the value of PI upto 10,000 digits after the decimal (3.1415.....). You can contact me on javagenious.com(At)gmal.com ; I would like to hear from you :)