我必須發送日文名字通過XMLHttpRequest。但它顯示編碼問題...我的tpl頁面是utf-8字符集。通過XMLHttpRequest發送日文字符
這裏是我的代碼。
function getFormData(dno,rno) {
var name = document.getElementById("f_nickname").value;
var digNo = dno;
var resNo = rno;
var strVal = digNo + "-" + resNo;
stp.push(strVal);
var xhr = new XMLHttpRequest();
if (!xhr) return false;
var url = 'ajax.php' + '?prc=' + 'diagnoses' + '&name=' + name + '&diagres=' + stp;
xhr.open('POST', url, true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send(stp);
return true;
}
我已經通過網址是這樣的:
http://crp.com/ajax.php?prc=diagnoses&name=大阪&diagres=0-0,1-3,2-2,3-3,4-3,5-2
,但它顯示在Ajax.php像
http://crp.com/ajax.php?prc=diagnoses&name=ƒsƒU&diagres=0-0,1-3,2-2,3-3,4-3,5-2
在許多方面試圖...如何解決? 在此先感謝...
您是否嘗試過設置'xhr.setRequestHeader(「Accept-Charset」,「unicode-1-1; q = 0.8」);'http://www.w3.org/Protocols/rfc2616/rfc2616-sec14。 html – JoSSte
我不希望它在這裏有所作爲,但是在把它們放入URI之前,你應該通過'encodeURIComponent'運行你的字符串。 – Quentin
「,但它顯示在Ajax.php像」 - 你如何測試? – Quentin