Problem with AJAX and Hebrew (or any other language)

Discussion in 'Javascript' started by ofiras, Apr 2, 2009.

  1. ofiras

    ofiras Guest

    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.
    ofiras, Apr 2, 2009
    #1
    1. Advertising

  2. ofiras wrote:

    > 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.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Apr 2, 2009
    #2
    1. Advertising

  3. ofiras

    ofiras Guest

    On 2 ×פריל, 12:50, Martin Honnen <> wrote:
    > ofiras wrote:
    > >   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.
    >
    > --
    >
    >         Martin Honnen
    >        http://JavaScript.FAQTs.com/


    Thank you very much!
    Ofir.
    ofiras, Apr 2, 2009
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Efy.
    Replies:
    2
    Views:
    1,080
  2. minnie
    Replies:
    1
    Views:
    665
    Andrew Thompson
    Dec 13, 2006
  3. Replies:
    7
    Views:
    1,069
  4. rl0103

    hebrew language support for windows ce

    rl0103, Apr 24, 2006, in forum: ASP .Net Mobile
    Replies:
    1
    Views:
    1,076
    Steven Cheng[MSFT]
    Apr 24, 2006
  5. balachandar
    Replies:
    4
    Views:
    74
    Lasse Reichstein Nielsen
    Sep 12, 2003
Loading...

Share This Page