<HTML>
<Title> ajaxstudy </title>
<Body>
<SCRIPT type = "text/JavaScript">
VaR XMLHTTP;
Function createhttprequest ()
{
Try
{
// Firefox, opera 8.0 +, Safari
XMLHTTP = new XMLHttpRequest ();
}
Catch (E)
{
// Internet Explorer
Try
{
XMLHTTP = new activexobject ("msxml2.xmlhttp ");
// IE6 +
}
Catch (E)
{
Try
{
XMLHTTP = new activexobject ("Microsoft. XMLHTTP ");
// Ie5
}
Catch (E)
{
Alert ("your browser does not support Ajax! ");
Return false;
}
}
}
}
Function ajaxfun ()
{
Createhttprequest ();
XMLHTTP. onreadystatechange = function ()
{
If (XMLHTTP. readystate = 4)
{
Document. myform. Time. value = XMLHTTP. responsetext;
Alert (XMLHTTP. readystate );
}
}
XMLHTTP. Open ("get", "Time. asp", true)
XMLHTTP. Send (null );
}
</SCRIPT>
<Form name = "myform">
User: <input type = "text" name = "username" onkeyup = "ajaxfun ()"/>
Time: <input type = "text" name = "time"/>
</Form>
</Body>
</Html>