473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Japanese charset support in GetXmlHttpObject()

66
Please tell everybody on how to support different languages using AJAX. I've been searching this for a long time in many forums in the internet but they did not solved or post the definite solutions.

Here's the printscreen: (please do copy and paste if not displayed here.)

output via php and html (http://anime.geocities.jp/rozvinbm_jp/shops.JPG)



output via php, html and processed with Ajax (http://anime.geocities.jp/rozvinbm_jp/shopsajax.JPG)




In addition, here is my code to explicitly defined the encoding:
[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=shift_jis">
......[/HTML]

Expand|Select|Wrap|Line Numbers
  1. var xmlHttp;
  2. var m_placeholder;
  3.  
  4. function executeProcess(serverscriptfile, placeholder, posts) {
  5.     xmlHttp=GetXmlHttpObject();
  6.     if (xmlHttp==null)
  7.     {
  8.         alert ("Browser does not support HTTP Request");
  9.         return;
  10.     }
  11.     m_placeholder = placeholder;
  12.     var url=serverscriptfile;
  13.     url=url+"?sid="+Math.random();
  14.     xmlHttp.onreadystatechange=stateChanged;
  15.     xmlHttp.open("POST", url, true);
  16.     xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=Shift-JIS'");
  17.     xmlHttp.send(posts);
  18. }
  19.  
  20. function stateChanged() {
  21.     if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  22.     {
  23.         document.getElementById(m_placeholder).innerHTML=xmlHttp.responseText;
  24.     }
  25. }
  26.  
  27. function GetXmlHttpObject() {
  28.     var xmlHttp=null;
  29.     try
  30.     {
  31.         // Firefox, Opera 8.0+, Safari
  32.         xmlHttp=new XMLHttpRequest();
  33.     }
  34.     catch (e)
  35.     {
  36.         //Internet Explorer
  37.         try
  38.         {
  39.             xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  40.         }
  41.         catch (e)
  42.         {
  43.             xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  44.         }
  45.     }
  46.     return xmlHttp;
  47. }
Aug 25 '07 #1
5 3192
eros
66
When the AJAX calls the php file, I've noticed the data in the $_POST are garbage data.

I think the problem is during GetXmlHttpObject execution to past the Posted data to php file.

Please teach me to set the charset in AJAX supporting Japanese charset.

Currently, I am using the following settings:

PostgreSQL ver 7.4.1 encoding: UNICODE

Javascript/AJAX code
Expand|Select|Wrap|Line Numbers
  1. xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=shift_jis'");
PHP code
[PHP]header('Content-Type: text/html; charset=shift_jis');[/PHP]

HTML code
[HTML]<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">[/HTML]
Aug 27 '07 #2
acoder
16,027 Expert Mod 8TB
See if this link helps.
Aug 27 '07 #3
acoder
16,027 Expert Mod 8TB
Merged threads.
Aug 27 '07 #4
eros
66
I cannot install the mbstring functions.
But I found iconv function.. it works well.

here's the php code:
[php]$str = iconv("UTF-8", "SJIS", $str);[/php]

I do the above code upon calling the php file by the XMLHttpRequest.

I have new problem when I release from the debugging season (on production). I will post new topic because it is not related in encoding.

Thank you very much.
Aug 28 '07 #5
acoder
16,027 Expert Mod 8TB
Glad you got this working. I'm sure your other problem will be solvable too.
Aug 28 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: David Thomas | last post by:
Hi there, I am trying to store data in a text file and output it to the browser using PHP. All very easy - if I was using English! the problem is, I want to use Japanese and I'm finding it a tad...
1
by: David Thomas | last post by:
Hi there, a while ago, I posted a question regarding reading japanese text from a text file. Well, since I solved the problem, I thought I'd post my solution for the benefit of other people with...
4
by: Leora Wenger | last post by:
We moved some pages of Japanese, Korean and Chinese from one server to another. In doing so, the users with Windows XP could still see the Asian fonts. However, a user with Windows 2000 could no...
2
by: Joseph | last post by:
Hello. I have this problem. See I have a transformed XML file and I checked its contents prior to outputting it to excel file via responseset. here is the gist of the code: XmlReader reader =...
21
by: Doug Lerner | last post by:
I'm working on a client/server app that seems to work fine in OS Firefox and Windows IE and Firefox. However, in OS X Safari, although the UI/communications themselves work fine, if the...
12
by: paulgor | last post by:
Hi, May be it's a know issue but my search brought nothing... We have static HTML files with Japanese text in UTF-8 encoding - it's on-line Help for our application, so there are no Web...
2
by: Victor | last post by:
Hi guys i am facing a real big problem here. I bought a hosting plan and try to build my own website. my website has several language version(chinese english japanese). but i just found out the...
0
by: eros | last post by:
How to supports Japanese characters. Problem: When I insert the data into database. The data inserted are garbage. Maybe there is configurations or code to be added at first. here is my...
2
by: eros | last post by:
var xmlHttp; var m_placeholder; function executeProcess(serverscriptfile, placeholder, posts) { alert(posts); xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.