Home >Web Front-end >JS Tutorial >The perfect solution to the automatic change of the plus sign and & sign in js passed parameters
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!