webservices

G

Guest

hi guys,

I have defined OnUnload event in body of a page to call Javascript.

<script language="javascript" type="text/javascript">

function myFunction()
{
var sessionID = document.Form1.tBoxSessionID.valu
mainSVC.useService("http://localhost/extranet/webservices/mainWebSVC.asmx?WSDL","dNtSvc");
var iCallID;
if (mainSVC.dNtSvc)
{
mainSVC.dNtSvc.callService("setLogOff", document.Form1.tBoxSessionID.value);
}
}
</script>

This webscript infacts updates database record with sessionid passed as
argument from javascript.
Now i know that the code is correct cuz if i put alert("Test") statement
before i call webservice, the record is updated but it dont if the
alert("Test") statement is not there.

Can someone tell me why this is the case? Does webservice stop executing if
the page is unloaded completely?

Thanks in advance.

Manny
 
L

Lucas Tam

Can someone tell me why this is the case? Does webservice stop
executing if the page is unloaded completely?

You can't really depend on the unload to fire reliably : (
 
S

Stefan

I am not sure, but I would think that mainSVC is destroyed before it
can establish the call to the web service.

Call service is an asynchronous call, meaning that it doesn't block or
wait. Which means that it could perfectly be that mainSVC as its "host"
could be destroyed before it established a connection to the ws (in
useService).

Since in the case when you put an alert before callService, useService
successfully established a connection, the callService can be invoked,
because mainSVC still exists. Of course, this is all pure speculation
and not based on any insight on how IE has implemented Unload.

Have you tried a JS-sleep before callService (basically to imitate an
alert)? Although an hack, this should work ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,744
Latest member
CortneyMcK

Latest Threads

Top