Close the page, the reason why the Window.location event was not executed

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.