<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<TITLE>JS Ajax encodeuricomponent coded PHP tutorial MySQL tutorial garbled problem </title>
<body>
var url = "Post.php?name=" +encodeuricomponent (names) + "&mo=" +encodeuricomponent (MOS) + "&body=" + encodeURIComponent (bodys) + "&id=" +<?= $id;? >;
Ajax part is not spoken, the main encodeuricomponent used to be garbled
</body>
PHP processing method,
$name = Iconv (' utf-8 ', ' gb2312 ', Postget (' name '));
Why convert Uft-8 to gb2312, because encodeuricomponent converts strings into coded formats using UTF-8 encoding. For the utf-8 is relatively simple, and urlencode is basically interchangeable, so if you are gb2312 the page must be converted.
Of course accept the page conversion, now want to gb2312 the page return data must be
$name = Iconv (' gb2312 ', ' Utf-8 ', Postget (' name '));
Returned to the Ajax return, this solves the Ajax PHP encodeuricomponent coding problem.