post亂碼問題

來源:互聯網
上載者:User
用AJAX POST方法傳遞到位save.php,save.php內容如下:
uXH=2302044520120101&uXM=臨時工&uXMPY=ls&uCYM=&uRXNY=&uNJ=&uBH=&uXSLBM=&uSFZH=&uXBM=&uXXM=&uCSRQ=&uCSDM=&uJGM=&uMZM=&uZJXY=&uGATQM=&uJKZKM=&uZZMMM=&uXZZ=&uHKSZD=&uHKXZM=&uLDRKZK=&uGBM=&uTC=&uLXDH=&uTXDZ=&uYZBM=&uDZXX=&uZYDZ=&uZP=&c_input_file=學生基本資料類&c_cxtj=username="bbb"
save.php內容如下:
session_start();
header('Content-Type:text/html;charset=GB2312');
include "conn.php";
//確定查尋檔案
@$b_input_file= $_POST['c_input_file'];
//確定查尋條件
@$b_cxtj=$_POST['c_cxtj'];
//選擇表或視圖
$b_sql="SELECT * FROM t_menu where name=".$b_input_file;
echo $b_input_file." | ".$b_cxtj." | ".$b_sql."
";
echo $_POST['uXMPY'];
?>
可是用document.getElementById("nr").innerHTML=myxmlhttp.responseText ;
得到的卻是:
“瀛???烘?淇?綾? | username="bbb" | SELECT * FROM t_menu where name=瀛???烘?淇?綾?ls”
是傳遞的是亂碼還是取加的是亂碼啊。
如何解決這個問題,謝謝。


回複討論(解決方案)

轉下編碼
iconv("gbk","utf-8",$_POST['XX'])

由於你使用的是 gb2312 頁面
ajax 端需用 encodeURIComponent 函數編碼中文參數串
接收後用 iconv 函數轉成你需要的編碼

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.