AJAX Made Easy - Learn AJAX

AJAX Categories

 
AJAX Home Learn-AJAX

How To Get Started With Ajax

Author: admin    |    Published: 4th May 2007     |    Read: 1997 times    |  Add Comment
Filed in: Learn-AJAX





How To Get Started With Ajax


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 doesn't 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 the server, 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 the JavaScript 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've 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 don't do this, some browsers like Firefox may not be capable of processing the request.


Conclusion


The next parameter you will need to consider is the URL of the page for which the request is being made. For security reasons, you cannot call the pages for a domain that is third party. You must use the proper domain name on all the pages or you will get the "permission denied" error when you call open ().





Post Comment


You need to Login to post your comment...

Click here to login

Title:

 
Comment:




Site Login

 

Sponsored Links

 

Related AJAX Articles

 » Enhancing Ajax Based Mash-up Application Security
 » MVC1 vs. MVC2 Vying for Ajax
 » Google’s AxsJax for Ajax Applications
 » SDLC Methodologies for Ajax
 » Things Everyone Needs to Know about Ajax
 » XML on Ajax
 » ActiveXObject in Ajax
 » Java Frameworks for Ajax
 » Oracle Development Kits for Ajax
 » Ajax Design Approach
 

Latest AJAX Articles

 

Popular AJAX Articles