How to solve the Chinese garbled problem in php ie get

藏色散人
Release: 2023-03-05 17:02:01
Original
1586 people have browsed it

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.

How to solve the Chinese garbled problem in php ie get

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)
 
    }
 
});
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!