Ajax request parameter escaping problem in JS jquery __jsp

Source: Internet
Author: User

A few days ago in the work, and mobile end of the interface to do when found that the front-end in the transfer of parameters when there are + or &, the server to get a string of + or & has become a space, the background Java program in parsing when the error!

The specific code is as follows:

$ (function () {var ISPC =! ( window.__detect.android| | window.__detect.ios| | Window.__detect.phone), Mooncakenums, mooncakeidentify= 0, <span style= "color: #ff0000;" >token = Usercookiecontrol.getcookie (' Authtoken '), App_args = token? ' &authtoken= ' +encodeuricomponent (token) + ' &from=m ': ',</span> Guagua_schma = ' Guagua://guagua::5: : 13:1;18:2 ',//guagua://guagua::8::21:2//exit login Address Logoutbackurl = ' http://event.guagua.cn/event/zhongqiu/index.html
  ';
    Prevents users from repeatedly submitting function Blockajax (delay) {var $elem = $ (' body '), Isblock = $elem. attr (' Data-block ');
    if (Isblock) return true;
    $elem. attr (' Data-block ', ' block ');
    settimeout (function () {$elem. removeattr (' Data-block '); }, delay| |
  1200);
    }//Login frame function Popuplogindlg () {if (ISPC) {//End login Guagualr._run (' l ');
    else {window.location.href = Guagua_schma;
    } function __checklogin () {var islogin = Checkloginstatus (); if (!islogin)Popuplogindlg (); Return!!
  IsLogin;
  //ios Home Hide Redemption button//if (Window.__detect.ios) $ (' #J_exchange_btn '). Hide ();
    Home Redemption button $ (' #J_exchange_btn '). Bind (' click ', Function (e) {e.preventdefault ();
    if (__checklogin ()) {window.location.href = './duihuan.html ';  }
});
From the mobile app's page cookie to obtain the user's login information (Authtoken) contains + and & symbol, resulting in the server to obtain Authtoken parsing error, the solution is to Authtoken URL escape. The code is as follows:

App_args  = token? ' &authtoken= ' +encodeuricomponent (token) + ' &from=m ': ',
This allows the server to get the normal Authtoken and resolve the user information.




Related Article

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.