PHP Website Development
Home | Contact Us | Sitemap

Custom Search

What is AJAX?


Ajax - an acronym of “Asynchronous JavaScript and XML” is a way of programming for the Websites, to get the tasks done without refreshing web pages. When your customer clicks on something on an Ajax driven application, there is very little lag time. The page simply displays what they're asking for. Google Maps and Yahoo mail are the best examples. The page updates almost before your eyes. There is very little lag and you don't have to wait for pages to refresh or reload. It gives user of web applications a rich experience of desktop applications.

Technically Ajax is a way of developing Web applications that combines: XHTML and CSS (Cascading Style Sheets) standards based presentation, Interaction with the page through the DOM, Data interchange with XML and XSLT, Asynchronous data retrieval with XMLHttpRequest and JavaScript to tie it all together. This saves web server processing time, since much of it is done on the client.

Traditionally, Web applications interact to server like:
User opens a web page -> User clicks to do something -> Browser sends HTTP Request to the server -> Server processes the request and sends data to browser. During this user sees blank page refreshing…

Ajax acts as an intermediary, The Ajax engine works within the Web browser (through JavaScript and the DOM) to render the Web application and handle any requests that the user might have of the Web server. The beauty of it is that because the Ajax engine is handling the requests, it can hold most information in the engine itself, while allowing the interaction with the application and the user to happen asynchronously and independently of any interaction with the server. Means If a user clicks a link, the request is sent to the server, which then sends the results back. Ajax is not a new technology, rather is a new way of looking at technology that is already mature and stable.




AJAX Basic Syntax
 
The basic framework structure of an Ajax-enabled web page. The following JavaScript shows how to send a request for an XML file and how to receive the returned request. This is the basics only you will need to refine and imlement better error handling. You will need to implement what to do with the returned XML.
Example #1 AJAX Structure
<script type="text/javascript">
/* -- Function to "handle" the response -- */
function myHandler(){
 /* -- Was the request successful? -- */
 if (this.readyState == 4 && this.status == 200) {
   /* -- Did the request return a result? -- */
  if (this.responseXML != null && this.responseXML.getElementById("stuff").firstChild.data) {
    doSomething(this.responseXML.getElementById("stuff").firstChild.data);
   }
 }
}


var myRequest; // Variable to hold request object
if(window.XMLHttpRequest){
 myRequest = new XMLHttpRequest(); // Standards-compliant browsers
}else if(window.ActiveXObject){
 myRequest = new ActiveXObject("Msxml2.XMLHTTP"); // For IE
}
 myRequest.onreadystatechange = myHandler;
/* -- "handleResponse.php" can be anything that returns an XML file -- */
 myRequest.open("GET", "handleResponse.php", true);
</script>
Our other websites
Free PHP Source Code Download    Free Bollywood News & Downloads   Free Funny SMS Text Messages
 
Home | About Us | Privacy Policy | Site Map | Contact Us

Copyright © 2009-2010 PHPWEBS