Home > Article > Backend Development > How to solve the Chinese garbled problem in php ie get
php ie get Chinese garbled solution: first open the corresponding PHP code file; then use the "encodeURI" statement to convert Chinese to URI encoding to solve the garbled problem.
Recommended: "PHP Video Tutorial"
php ie get Chinese garbled solution:
1. Solving the problem of Chinese garbled characters in the get method URL under IE
I recently encountered a problem when working on a project. Under Chrome, when using the ajax get method to request data , there is no problem with Chinese characters in the URL, but under IE, the Chinese characters will be turned into garbled characters and sent over, making it impossible to obtain the data.
At first I thought of letting the server parse it to solve the problem, but since it was already garbled when sent, the server could not parse the garbled code.
2. Later I thought of a way: use the encodeURI method to convert Chinese to URI encoding, which can perfectly solve the problem of garbled characters and is compatible with all browsers.
The specific code is as follows:
var url = encodeURI("http://xxx.xxx.xxx.23?" + 中文); $.ajax({ type:"get", url:url, dataType:"json", success:function(data){ console.log(data) }, error:function(err){ console.log(err) } });
The above is the detailed content of How to solve the Chinese garbled problem in php ie get. For more information, please follow other related articles on the PHP Chinese website!