<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> No title page </title>
</Head>
Code
< Script Type = " Text/JavaScript " >
VaR Timeout = Null ; // Setinterval function handle
VaR XMLHTTP = False ; //
Function Sendrequest ()
{
// XMLHTTP = false;
If (Window. activexobject)
{
Try
{
XMLHTTP = New Activexobject ( " Msxml2.xmlhttp " );
}
Catch (E)
{
XMLHTTP = New Activexobject ( " Microsoft. XMLHTTP " );
}
}
Else If (Window. XMLHttpRequest)
{
XMLHTTP = New XMLHttpRequest ();
}
Else
{
Alert ( ' Initialization error! ' );
Return ;
}
VaR URL = " Handler. ashx " ;
// VaR url = "default2.aspx ";
XMLHTTP. Open ( " Get " , URL, True );
XMLHTTP. onreadystatechange = Showdata;
XMLHTTP. Send ( Null );
}
Function Showdata ()
{
If (XMLHTTP. readystate = 4 )
{
If (XMLHTTP. Status = 200 )
{
VaR Tag = Document. getelementbyid ( " Container " );
Tag. innerhtml = "" ;
Tag. innerhtml = XMLHTTP. responsetext;
}
}
}
// Start auto refresh
Function Update ()
{
Timeout = Window. setinterval ( " Sendrequest () " , 1000 ); // Set one second to call the default2.aspx page
}
// Stop auto refresh
Function Stopupdate ()
{
If (Timeout ! = Null )
{
Window. clearinterval (timeout );
}
}
< / SCRIPT>
<Body onload = "sendrequest ();">
<Form ID = "form1" runat = "server">
<Div>
<Input type = "button" value = "start fresh" onclick = "Update ();"/>
<Input type = "button" value = "Stop fresh" onclick = "stopupdate ();"/>
<Input id = "button1" type = "button" value = "OK" onclick = "sendrequest ();"/>
</Div>
</Form>
<Div id = "Container"> <! -- Container --> </div>
</Body>
</Html>