In the URL pass parameter, there are some special characters, these symbols in the URL is not directly passed, if you want to pass these special symbols in the URL, then use their code.
Some URL special symbols and encoded hexadecimal values are listed in the following table
1. + URL + sign space%2b
2. Spaces in the URL can be used with + or encoding%20
3./delimited directory and subdirectory%2f
4.? Separating the actual URLs and parameters%3f
5.% Specify special character%25
6. # indicates bookmark%23
7. & separator Between the parameters specified in the URL%26
8. = value of the specified parameter in the URL%3d
Way to solve:
Replace () method if directly with Str.replace ("-", "!") Only the first matching character will be replaced.
and Str.replace (/\-/g, "!") You can replace all the matching characters (G is the global flag).
Replace ()
The substitution character variables in JS are as follows:
Data2=data2.replace (/\%/g, "%25");
Data2=data2.replace (/\#/g, "%23");
Data2=data2.replace (/\&/g, "%26");