0

영어와 태국어로 사용할 수있는 키워드 목록을 반환하는 notfound.php 파일이 있습니다. 내가 가지고있는 브라우저 중 하나를 사용하여 페이지를 요청하면 제대로태국어가 잘못 표시되었습니다.

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

태국어 디스플레이를 포함하고, 여기서 타이어 잘못 자바 스크립트를 사용하여 동일한 파일을 호출 할 때 출력합니다.

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에서만 올바르게 표시됩니다.

+0

"타이어가 잘못 출력됩니다" 무엇이 출력됩니까? 무엇을 출력해야합니까? 인코딩 문제라고 생각합니다. – Scimonster

+0

대신에 ภาษา ไทย 예, xmlhttp 만 사용하여 발생하는 인코딩 문제 – alberto

+1

'utf-8'을 (를) 대신 반환하도록 변경할 수 없습니까? – tia

답변

0
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); 
} 
+0

이 (가) 제안한대로 변경되었습니다. 같음 : Chrome에서만 올바름 – alberto

+0

xmlhttp.overrideMimeType ("text/plain; charset = tis-620")을 시도했습니다. 대부분의 브라우저에서 작동하며 타이 텍스트가 이제는 올바르지 만 IE 9에서 작동하지 않습니다. 'overrideMimeType 이 객체의 속성이 아닙니다. – alberto

+0

오후 내내이 곳을 보냈습니다. xmlhttp가 타이 언어를 올바르게 표시하게하려면 서버에 대한 모든 요청 (GET/POST는 마음에 들지 않습니다)은 요청 된 파일에 PHP 헤더가 있어야합니다. 헤더 ("Content-type : text/xml; charset = tis-620") alberto

관련 문제