Sponsered Links
Categories
Sponsered Links

Ajax XmlHttpRequest Example

 

This is a simple Ajax XmlHttpRequest Example.

<html>
<body>

<script language="javascript" type="text/javascript">
   function ajaxFunction(){
   var ajaxRequest;

try{
   ajaxRequest = new XMLHttpRequest();
} catch (e){
try{
   ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
   ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
   alert("Your browser broke!");
return false;
}
}
}
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
   document.myForm.time.value = ajaxRequest.responseText;
}
}
ajaxRequest.open("GET", "serverTime.php", true);
ajaxRequest.send(null);

}

</script>

        <form name='myForm'>
            Name: <input type='text' onChange="ajaxFunction();" name='username' /> <br />
            Time: <input type='text' name='time' />
        </form>
</body>
</html>


 
 
Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved