![]() |
AJAX Basics
It is highly recommended that you are familiar with HTML and Javascript before reading tutorial. Notice that this article is only glimpse on this topic, it barely covers all the AJAX features and stuff.
This tutorial will show you how 'Ajax' works and how to use it from a web developer's standpoint. Ever wondered how things like G-Talk work? They don't reload the page or use Iframes and yet they always appear to have the data thats coming in instantly. It accomplishes this using Ajax. Ajax is not a language of its own, so if you know JavaScript and HTML, you are ready. AJAX is not a new programming language, but a new way to use existing standards. Ajax loosely stands for Asynchronous JavaScript And XML. XML is commonly used as the format for receiving server data, although any format, including plain text, can be used. AJAX is a web browser technology independent of web server software. AJAX is based on the following open standards:
With AJAX when submit is pressed, JavaScript will make a request to the server, interpret the results and update the current screen. In the purest sense, the user would never know that any data were even sent to the server. A user can continue to use the application while the client program requests information from the server in the background. This is where it all comes from, the ability to send and receive data without reloading the page. First, you need to create an object though. Firefox, Opera, Safari: Code:
var xmlhttp=new XMLHttpRequest;Code:
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");Code:
xmlhttp=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");Code:
function getnamedata()The handler function gets called every time that xmlhttp changes state. We have the if statement so that it will only execute when readyState==4 (4 is completed). The last statement of course retrieves the data from the xmlhttp object. If you are getting most types of data you should use the responseText property, for actual XML data use the responseXML property. The last statement just closes the socket for later use. Using this as a basic model you can make an entire website live if you want to, or just find something fun to do with it. |
Re: AJAX Basics
Great tutorial! Would you consider making a tutorial on using AJAX to populate charts or other graphs on a website?
|
Re: AJAX Basics
Quote:
|
| All times are GMT +5.5. The time now is 08:35. |