1, Problem Description:
JS defines widow.location = function (), and when the page closes, the logout () function is not executed.
Window.onunload =function() {logout (); }functionLogout (Reqparam, callback) {varUsermanageserviceurl = "http//" + getserveraddr () + "/axis2/services/usermanageservice"; varUrllist = []; varURL =window.location.href; Urllist= Url.split ("?"); varSessionID = urllist[1]; Reqparam.sessionid=SessionID; varPL =Newsoapclientparameters (); varReqparamstr =json.stringify (Reqparam); Pl.add ("Reqparam", REQPARAMSTR); Soapclient.invoke (Usermanageserviceurl,"Logout", pl,false, callback); }
2, the cause of the problem:
Call the Soapclient.invoke () method in Logout (), the parameter is true, which means that the front end and server are asynchronous communication, that is, the front end has not received a response from the server side, it has executed the following statement, in which the performance of the front-end execution Logout ( ) has not yet waited for the server to respond, the page has been closed, so the performance is logout () is not executed.
3. Solution:
The problem is resolved by changing the front-end and server communication mode to synchronous, and changing the Soapclient.invoke () method to True to false.
Close the page, the reason why the Window.location event was not executed