Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9063917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:07:09+00:00 2026-06-16T16:07:09+00:00

I’m having this code which seem to screw up itself when the text in

  • 0

I’m having this code which seem to screw up itself when the text in the XMLHttpRequest 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:

  1. doubles the size of the file
  2. the hardware that writes some of the data in that html file, write it in ASCII

The small example just load itself:

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

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 jQuery stuff).

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:07:10+00:00Added an answer on June 16, 2026 at 4:07 pm

    Ok, I’m not sure what the web server of XAMPP sends for the specific HTML I use, but on the specific hardware, we wrote the web server and it sends:

    HTTP/1.1 200 OK
    MIME-version: 1.0
    Content-Type: text/html
    Content-length: 11280
    Proxy-Connection: Keep-Alive
    Connection: Keep-Alive
    Age: 0
    

    One solution would be saving the web page as Unicode, which will not be good for us.
    The other option, which seem to work, is to tell the browser that we want a specific encoding.
    In this case Windows-1255.

    All I had to do, is to change the header that is sent from the website so it will also contain the charset, and now it works fine:

    HTTP/1.1 200 OK
    MIME-version: 1.0
    Content-Type: text/html; charset=Windows-1255
    Content-length: 11280
    Proxy-Connection: Keep-Alive
    Connection: Keep-Alive
    Age: 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a text area in my form which accepts all possible characters from
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have an array which has BIG numbers and small numbers in it. I
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.