1, the problem description:
JS defines widow.location = function (), the logout () function is not executed when the page closes.
Window.onunload = function () {
logout ();
}
function logout (Reqparam, callback) {
var usermanageserviceurl = "http://" + getserveraddr () + "/axis2/services/" Usermanageservice ";
var urllist = [];
var url = window.location.href;
Urllist = Url.split ("?");
var SessionID = urllist[1];
Reqparam.sessionid = SessionID;
var pl = new Soapclientparameters ();
var reqparamstr = json.stringify (Reqparam);
Pl.add ("Reqparam", reqparamstr);
Soapclient.invoke (Usermanageserviceurl, "logout", pl, False, callback);
}
2, the problem reason:
The Soapclient.invoke () method is called in logout (), and the argument is true, which means that the front-end and server communicate asynchronously, that is, the front-end has not received a response from the server side, and the following statement has been executed, which is performed as a front-end execution logout ( has not yet waited for the server's response, the page has been closed, so the performance of logout () has not been performed.
3, the solution:
Change the front-end and server communication mode to sync, and the problem is resolved by changing the Soapclient.invoke () method to False.