Parameters passed by the POST method in Ajax will be lost &, %, + ', escape

Source: Internet
Author: User

In Ajax, the post escape cannot be converted to some special characters, such as: + % &, so it must be escaped.

Otherwise, this character will be lost during HTTP transmission. In this case, you must manually convert "+" to "% 2B ", the characters to be manually converted include "&"-> "% 26", "%"-> "% 25. These special characters cannot be encoded using the Javascript encodeuri (). Therefore, even if you are "stupid", manual conversion is impossible. However, apart from the three stubborn guys, it is not found that other characters also need to be converted when the XML text is submitted in post mode.

If (password! = NULL & password! = "") <Br/>{< br/> Password = password. replace (/\ +/g, "% 2B"); <br/> Password = password. replace (// G, "% 26"); <br/>}< br/> If (username! = NULL & username! = "") <Br/>{< br/> username = username. replace (/\ +/g, "% 2B"); <br/> username = username. replace (/\ &/g, "% 26"); <br/>}</P> <p> Note: + is a metacharacter of a regular expression, \ escape is required. & escape is not required.

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.