Home > Article > Backend Development > Halo theme mjolnir mix php+AJAX solution to the problem that sending Chinese will cause garbled characters
//If the transmission parameters are given directly, garbled characters will be generated!
Copy the code The code is as follows:
http_request.open("POST",url,true);
http_request.setRequestHeader('Content- Type', 'application/x-www-form-urlencoded');
http_request.send("action="+strName+"&val="+val); //If the value of val is Chinese, garbled characters will be generated
Copy the code The code is as follows:
http_request.open("POST",url,true);
http_request.setRequestHeader('Content -Type', 'application/x-www-form-urlencoded');
http_request.send("action="+strName+"&val="+escape(val)); //The value of val is Chinese and will not produce garbled characters
Copy code The code is as follows:
PHP:header('Content-Type:text/html;charset=GB2312');
ASP:Response.Charset("GB2312")
JSP:response.setHeader ("Charset","GB2312");
The above introduces the solution to the problem that halo theme mjolnir mix php+AJAX will cause garbled characters when transmitting Chinese, including the content of halo theme mjolnir mix. I hope it will be helpful to friends who are interested in PHP tutorials.