Hi, i'm trying a code to update a html div using ActiveX or
XMLHttpRequest from client side and a asp.net page that retrieve data.
The asp.net page is a loop for some seconds and then i do it again the
request.
My javascript from client side is like this:
function Tracking(U,M,V){
var a=window.ActiveXObject?new window.ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest;
try{a.open(M,U,true);a.send(V);}catch(c){a=null;alert('Exception: '+c);}return a;
}
var MyRequest=Tracking('async/mypage.aspx?_r'+(Math.random()*999).toString(),'get',null);
function Abort(){MyRequest.abort();}
function ViewRequest(){
/*
Some code
MyRequest.responseText ....
*/
}
And the server side:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim StartDate As Date = Now
While Now.Subtract(StartDate).Seconds < 15
' Response.Write (something)....
Response.Flush()
Response.Clear()
System.Threading.Thread.Sleep(50)
End While
End Sub
Now, when i try abort the page request by client side, i call the function Abort and the request is stopped but mypage.aspx still in
execution to complete the operation for some seconds. How i do it to stop the execution before 15 seconds by client script?
any idea on how I can do this?
Thanks
XMLHttpRequest from client side and a asp.net page that retrieve data.
The asp.net page is a loop for some seconds and then i do it again the
request.
My javascript from client side is like this:
function Tracking(U,M,V){
var a=window.ActiveXObject?new window.ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest;
try{a.open(M,U,true);a.send(V);}catch(c){a=null;alert('Exception: '+c);}return a;
}
var MyRequest=Tracking('async/mypage.aspx?_r'+(Math.random()*999).toString(),'get',null);
function Abort(){MyRequest.abort();}
function ViewRequest(){
/*
Some code
MyRequest.responseText ....
*/
}
And the server side:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim StartDate As Date = Now
While Now.Subtract(StartDate).Seconds < 15
' Response.Write (something)....
Response.Flush()
Response.Clear()
System.Threading.Thread.Sleep(50)
End While
End Sub
Now, when i try abort the page request by client side, i call the function Abort and the request is stopped but mypage.aspx still in
execution to complete the operation for some seconds. How i do it to stop the execution before 15 seconds by client script?
any idea on how I can do this?
Thanks