Recently, when I was passing special characters with url, I found that the data was lost.
Actually it is not lost, for example, '+' will be processed as a connection character.
1. Replace with hexadecimal characters, and several commonly used conversions in this column
| + | Spaces | / | ? | % | & | = | # |
| %2B | %20 | %2F | %3F | %25 | %26 | &3D | %twenty three |
Copy the code as follows: var post_Str = apply_name.replace(//+/g, "%2B");//"+" escape
var post_Str= post_Str.replace(//&/g, "%26");//"&"
var post_Str= post_Str.replace(//#/g, "%23");//"#"
2. If you encounter other special characters, you can use the following method to see what to convert them into. Just write one according to the above method.
Copy the code as follows: alert(encodeURIComponent("-"));//Transcoding, the result is OK, the following is decoding, it is not available here
alert(decodeURIComponent(encodeURIComponent("#")));