/ Published in: JavaScript
Expand |
Embed | Plain Text
<html> <head> <title> </title> <script type="text/javascript"> //check the code for IE browsers ,and javascript version 5 if(window.ActiveXObject) { xmlhttp = new ActiveXObeject("MSxml2.XMLHTTP"); } // check if the older version of javascript support else if(window.ActiveXObject) { xmlhttp = new ActiveXObeject("Microsoft.XMLHTTP"); } //this is code for IE7+,Opera,Safari,Chrome,Mozilla else if(window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } function work() { var obj =document.getElementById("myDiv"); // u need to create a file of file name ajax_info.php xmlhttp.open("GET","/ajax_info.php",true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 ) //where 4 indicates that the request and response have done, similarly there r 0,1,2 and 3 { obj.innerHTML=xmlhttp.responseText; } } xmlhttp.send(null); } </script> </head> <body> <div id="myDiv"><p>Ajax comes here<p> </div> <input type="submit" value="Click" name="submit" onclick="work()"> </body> </html>
Comments
Subscribe to comments
You need to login to post a comment.

I wonder: isn|'t the query in line 14 exactly the same as in line 9?
yeah there r exactly same