0

hi,

i am a newbie to ajax. i have created 2 html file in the following :-

<<< a.html >>>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>Admin Page</title>
<script>
function loadURL(cDiv, cURL, cGetPost, cParam)
{
    var xmlhttp;
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            document.getElementById(cDiv).innerHTML=xmlhttp.responseText;
        }
    }
    xmlhttp.open(cGetPost,cURL,true);
    xmlhttp.setRequestHeader("Content-Type","text/html;charset=big5");
    xmlhttp.send(cParam);
}
</script>
</head>
<body>
<div id="page-container"><a href="#" onclick="loadURL('content_detail','b.html','POST','');return true;">click here</a></div>
<div id="content_detail"></div>
</body>
</html>

<<< b.html >>>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>Untitled Document</title>
</head>
<body>
<p>程式測試</p>
<p> </p>
</body>
</html>

by clicking the 'click here' button, instead of display chinese character, the result show '�{�����', is there anyone can tell me what mistake i have made ? pls help, thanks

2
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by Taywin
0

Have you tried to display it using unicode (i.e. &#31243;&#24335;&#28204;&#35430;) instead of typing real Chinese character inside your HTML file content? You can look up for Chinese character unicode here.

Edited by Taywin

0

hi Taywin,

it works. i believe the problem is due to the chinese conversion problem, and i have many big5 html file which i cannot afford to change all to unicode, is there any way we can convert on the ajax program ?

0

Hmm... I think the problem comes from Ajax. I guess it doesn't support character set when it goes through the Internet layer (regardless your char set declaration on the page). That's why unicode is the best for character display when it comes to non-english characters.

I do not know how to force it to read the real Chinese character via file from the Internet. If there are so many files the way you explain, what I would do is to write a script that read in each file and replace each character. Even though, it may take equally or longer time compared to manually replace all files by hand, you could still use the script to do the similar work in the future. Anyway, the task is not that simple regardless...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.