The Chinese parameter processing code is passed in Ajax:
The code is as follows |
Copy Code |
JS in: Send_request (' http://www.111cn.net/mini_do.php?username= ' + encodeuri (username) + ' &phone= ' + encodeuri (phone) + ' &content= ' + encodeuri (content)); In mini_do.php: $username = UrlDecode ($_request[username]); $phone = UrlDecode ($_request[phone]); $content = UrlDecode ($_request[content]); |
Finally, a friend said you can use the Escape function
var htmer = "getcode=" +escape (getcode) + "&content=" +escape (Content);
This I do not build righteousness oh, because it's a higher error. Some Chinese characters are not recognized, there is a function encodeuricomponent this is more comprehensive
encodeURIComponent, it 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)
Summarize
Judging from the above
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
The coding range is the best choice for us to choose encodeURI.