Problem with AJAX and Hebrew (or any other language)

O

ofiras

Hello,
I made an AJAX script that gets data from a PHP file, and feeds a div
with this data. The PHP file is sending data in Hebrew, but the AJAX
somehow feeds the div with question marks instead of letters. Dose
someone knows why is it so?

This is my AJAX script:

//Script start

function getHTTPObject(){
if (window.ActiveXObject)
return new ActiveXObject('Microsoft.XMLHTTP');
else if (window.XMLHttpRequest)
return new XMLHttpRequest();
else {
alert('Your browser does not support AJAX.');
return null;
}
}

function doWork(){
httpObject = getHTTPObject();
if (httpObject != null) {
httpObject.open('GET', 'online_users.php', true);
httpObject.send(null);
httpObject.onreadystatechange = function(){
if(httpObject.readyState == 4){
document.getElementById('div1').innerHTML = httpObject.responseText;
}
}
}
}

doWork();

setTimeout('doWork()',30000);

//Script end


And this is the PHP file (if it matters...):

//PHP script start

<?php
print "×”×™×™";
?>

//PHP script end

And what I get is "��".
Thanks,
Ofir.
 
M

Martin Honnen

ofiras said:
document.getElementById('div1').innerHTML = httpObject.responseText;

And this is the PHP file (if it matters...):

//PHP script start

<?php
print "×”×™×™";
?>

//PHP script end

And what I get is "��".


Well find out which encoding your PHP sends its stuff with and then set
a HTTP header e.g.
header('Content-Type: text/html; charset=Windows-1255');
in the PHP script before you send any content. Note that Windows-1255 is
just an example, I don't know which encoding your PHP script sends its
data with.
 
O

ofiras

Well find out which encoding your PHP sends its stuff with and then set
a HTTP header e.g.
header('Content-Type: text/html; charset=Windows-1255');
in the PHP script before you send any content. Note that Windows-1255 is
just an example, I don't know which encoding your PHP script sends its
data with.

Thank you very much!
Ofir.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top