//如果传送参数是直接赋予的,就会产生乱码!
复制代码 代码如下:
http_request.open("POST",url,true);
http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
http_request.send("action="+strName+"&val="+val); //如果val的值为中文,则产生乱码
复制代码 代码如下:
http_request.open("POST",url,true);
http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
http_request.send("action="+strName+"&val="+escape(val)); //val的值为中文不会产生乱码
复制代码 代码如下:
PHP:header('Content-Type:text/html;charset=GB2312');
ASP:Response.Charset("GB2312")
JSP:response.setHeader("Charset","GB2312");