During this time of the project, encountered a difficult browser compatibility problem, the problem is mainly in the jquery Getjson function function, but the root problem is still out in the code, see a more clearly written on the JS code used to introduce the function, later encountered in Chinese to remember to the URL code.
JS encoding text involves 3 functions: Escape,encodeuri,encodeuricomponent, corresponding 3 decoding functions: Unescape,decodeuri,decodeuricomponent
1, the transfer of parameters need to use encodeuricomponent, so that the combination of the URL will not be # and other special characters truncated.
For example: <script language= "JavaScript" >document.write (' <a href= ' http://passport.baidu.com/?logout&aid=7 & u= ' +encodeuricomponent ("http://cang.baidu.com/bruce42") + ' "> Exit </a& gt; '); </script>
2, the URL jump can be used as a whole encodeURI
For example: location.href= "/encodeuri" ("http://cang.baidu.com/do/s?word= Baidu &ct=21");
3, JS use of data can use escape
For example: History records in the search of Tibet.
4, Escape to encode the Unicode value other than 0-255, output%u**** format, in other cases escape,encodeuri,encodeuricomponent encoding results are the same.
The most used should be encodeuricomponent, which is to convert Chinese, Korean and other special characters into utf-8 format URL encoding, So if you need to use encodeURIComponent when passing parameters to the background, you need background decoding for utf-8 support (the form is encoded in the same way as the current page encoding)
Escape does not encode 69 characters: *,+,-,.,/,@,_,0-9,a-z,a-z
There are 82 encodeURI not encoded characters:!,#,$,&, ', (,), *,+,,,-,.,/,:,;,=,?,@,_,~,0-9,a-z,a-z
There are 71 encodeuricomponent characters that are not encoded:!, ', (,), *,-,.,_,~,0-9,a-z,a-z
According to the instructions, I need the encodeURIComponent function.
--------------------------------------------------------------------------------------------------------------
According to the above mentioned
1, the browser, the form of the URL is consistent with the page code
2. The URL sent by the browser with the XMLHTTP is consistent with the browser default settings
3, the request URL and the server is consistent without garbled appearance
PS: The recommended use of encodeURIComponent (), with its encoded URL and PHP UrlEncode () function results consistent with the most convenient interaction.
The original text in this