Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 泰语错误显示:_Javascript_Xmlhttprequest_Thai_Southeast Asian Languages - Fatal编程技术网

Javascript 泰语错误显示:

Javascript 泰语错误显示:,javascript,xmlhttprequest,thai,southeast-asian-languages,Javascript,Xmlhttprequest,Thai,Southeast Asian Languages,我有一个文件notfound.php,它返回可用的英语和泰语关键字列表。 它包含 metahttp equiv='Content-Type Content='text/html;字符集=tis-620’。 如果我使用我拥有的任何浏览器请求页面,泰语会正确显示,在使用JavaScript调用同一文件时,泰语输出错误 document.getElementById("area").innerHTML=xmlhttp.responseText; xmlhttp.open("GET","notfound

我有一个文件
notfound.php
,它返回可用的英语和泰语关键字列表。 它包含

metahttp equiv='Content-Type Content='text/html;字符集=tis-620’。

如果我使用我拥有的任何浏览器请求页面,泰语会正确显示,在使用JavaScript调用同一文件时,泰语输出错误

document.getElementById("area").innerHTML=xmlhttp.responseText;
xmlhttp.open("GET","notfound.php?&mat=" + Math.random(),true);
xmlhttp.send();
此片段来自一个文件,该文件也包含

meta-http equiv='Content-Type'Content='text/html;charset=tis-620
'

返回到“区域”的文本仅在Chrome中正确显示。

函数sendByAJAX(){
function sendByAJAX() {
   // get the user text and make it safe for HTTP transmission
   var userTxt = encodeURIComponent( document.getElementById('userTxt').value );
   // create the AJAX object
   var xmlhttp = new XMLHttpRequest();
   // assume successful response -- do NOT actually make this assumption in real code
   xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState==4 && xmlhttp.status>=200 && xmlhttp.status<300) {
         // You'll probably want to do something more meaningful than an alert dialog
         alert('POST Reply returned: status=[' + xmlhttp.status + 
        ' ' + xmlhttp.statusText + ']\n\nPage data:\n' + xmlhttp.responseText);
      }
   }
   xmlhttp.open('POST', 'http://www.site.com/submit/path');
   // here we are overriding the default AJAX type, 
   // which is UTF-8 -- this probably seems like a stupid thing to do
   xmlhttp.setRequestHeader('Content-type', 
    'application/x-www-form-urlencoded; charset=tis-620;');
   xmlhttp.setRequestHeader('User-agent'  , 'Mozilla/4.0 (compatible) Naruki');
   xmlhttp.send(userTxt);
}
//获取用户文本并确保HTTP传输安全 var userTxt=encodeURIComponent(document.getElementById('userTxt').value); //创建AJAX对象 var xmlhttp=new XMLHttpRequest(); //假设响应成功——不要在实际代码中实际进行此假设 xmlhttp.onreadystatechange=函数(){
如果(xmlhttp.readyState==4&&xmlhttp.status>=200&&xmlhttp.status>“输出错误”,它会输出什么?应该输出什么?我猜这是一个编码问题。������ 不如ภาษาไทย 是的,只有使用xmlhttp时才会出现编码问题。你不能改为返回utf-8吗?按照你的建议更改了get to post。相同:仅在Chrome中正确我尝试过xmlhttp.OverrideMetype(“text/plain;charset=tis-620”)。它可以在大多数浏览器中使用,泰语文本现在是正确的,但在IE9中不起作用,IE9抱怨“OverrideMemetype不是此对象的属性。为此花了整个下午。要使xmlhttp正确显示泰语,对服务器的所有请求(GET/POST不要紧)必须在请求的文件中有一个php头:头(“内容类型:text/xml;charset=tis-620“),位于