XMLHttpRequest with Hebrew Characters

SATANA-GOD

New Member
I'm having this code which seem to screw up itself when the text in the \[code\]XMLHttpRequest\[/code\] contains Hebrew characters, so I've made a small example to demonstrate the problem.The small code example loads the page and then replaces the content of a div with the content it got from the server.Since it calls the same webpage then it should replace it with the same content.The code works fine when the button inside the div contains letters in English, but if the letters are beyond ASCII 127 then it screws the button.I've made some tests and saw that if I save the file as Unicode, then it works ok...The problem is that I can't save this file as Unicode since it:[*]doubles the size of the file[*]the hardware that writes some of the data in that html file, write it in ASCIIThe small example just load itself:\[code\]<HTML><HEAD><TITLE>Test</TITLE></HEAD><BODY onload="readPage()"><Div id='Hello'><Button>????</Button></Div><Script>var xmlHttp;function readPage(){ xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="/xampp/2.html?dummy=" + new Date().getTime(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url, true); xmlHttp.setRequestHeader("Content-Type", "text/plain;charset=ISO-8859-1"); xmlHttp.setRequestHeader("Accept-Charset", "ISO-8859-1"); xmlHttp.send(null);}function stateChanged(){ if (xmlHttp.readyState==4) { var x = ""; //alert(xmlHttp.responseXML); //alert(xmlHttp.responseText); if (xmlHttp.responseText.match(/<Div id='Hello'>([\s\S]*?)<\/Div>/i)) { x = xmlHttp.responseText.match(/<Div id='Hello'>([\s\S]*?)<\/Div>/i)[1]; //x = x.replace(/"/g,''); var pdata= http://stackoverflow.com/questions/13877036/document.all ? document.all["Hello"] : document.getElementById("Hello"); alert(pdata.innerHTML); alert(x); pdata.innerHTML=x; alert(pdata.innerHTML); } }}function GetXmlHttpObject(){ var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp;}</Script></BODY></HTML>\[/code\]I tried changing the char set and the content type, but it doesn't work.What am I doing wrong?(btw, I cannot use any \[code\]jQuery\[/code\] stuff).Thanks.
 
Back
Top