Home > Web Front-end > JS Tutorial > body text

The perfect solution to the automatic change of the plus sign and & sign in js passed parameters

高洛峰
Release: 2017-02-16 17:11:56
Original
1323 people have browsed it

The following editor will bring you a perfect solution to the automatic change of the plus sign and & sign in js passing parameters. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let's follow the editor and take a look.

Use the get method in the action to obtain the parameters. If there is "+" in the parameter, it needs to be processed, otherwise it will become a space in the background.

Solution:

1. Use post method instead;

2. Use url in js = encodeURI(encodeURI(XXX)), decode again in the background;

3. Directly replace the escape when passing parameters, or directly write the escaped code

  data = "a + b";
  data = data.replace(/\+/g, "+");
  data = data.replace(/\&/g, "&") ;

Or:

Data = "a + b";
data = "a & b";

The above is the perfect js solution that the editor brings to you The entire method of automatically changing the plus sign and ampersand in passing parameters has been covered. I hope everyone will support the PHP Chinese website~

For more perfect solutions to the method of automatically changing the plus sign and ampersand in js passing parameters, please read related articles. Follow PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!