Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1007
  • Last Modified:

jQuery.ajax handling returned Russian/Chinese HTML data

I have a script that seems to work fine and gets the data back from the server ok for West European Languages. When I try to get Russian or Chinese etc. data, it does not display correctly on the browser.

It must be able to handle many languages like does
<script src="jquery.js" type="text/javascript" language="javascript" charset="utf-8"></script>
<script src="jquery.form.js" type="text/javascript" language="javascript" charset="utf-8"></script>
<script language="javascript" type="text/javascript">
$.ajax({url: '/cgi-bin/ajaxpost.dll/send', 
        type: 'POST', 
		dataType: 'html',
		contentType: 'text/html; charset=koi8-r',
//		contentType: "text/html; charset=utf-8",
		success: function(data){$(s1).html(data)},
		data: $('#form1').formToArray()

Open in new window

  • 5
  • 4
1 Solution
Alfred9847Author Commented:
Thank you cdaugustin for having a stab at this. Unfortunately, I don't use PHP so the articles you mentioned don't lead me very far.

On the other hand, since the responses have been slow getting to me, I have been working on another approach whereby the server does the translation to UTF-8 before sending it and the snippet of code above is left unchanged.

I have been using the Delphi Inspiration components to do so 

So far, I have managed to do it for Western European Languages, Russian, Ukrainian, Simplified Chinese and am now busy on Korean.

These components have been sitting on my PC for years and I never had a chance to try them out. Obviously, I would prefer a Javascript solution so I am keeping this question open.

as sugested from my links this is not a javascript problem, but rather a product wide encoding problem. A fix on the JS side would fix only part of your issue. Unfortunatly I cannot help you with Delphi but it would have helped to give more info about your dev environment, im sure there are some Delphi guys out there who have the know how.

good luck
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Alfred9847Author Commented:
Thank you again cdaugustin. I don't really see it as a Delphi problem or a PHP problem. I see it as a Javascript problem. By resorting to server-side programming, I am using a sledgehammer to crack a nut. does it quite happily in Javascript and it is that that I would like to be able to replicate. :=)
hmmm, ok, but usually charset problems are compound  problems, check the data that your server script is outputting, then make sure the client is using/having the needed charsets available.
in your case you  would need to see the data the js is trying to send, try to look at it "raw" on the server side.
Alfred9847Author Commented:
<< check the data that your server script is outputting, then make sure the client is using/having the needed charsets available.>>

The server is sending JSON data that contains KOI8-RU  (for Russian), GB 18030 (for Chinese) etc. The webpage is UTF-8 and so Javascript has to handle the conversion depending on the language selected for translation.

<< you  would need to see the data the js is trying to send, try to look at it "raw" on the server side.>>

It is just a regular POST - nothing special there.
if you sure its not transport related, then take a look at

and subsequently at the

hopefully this will help you out. my above advices were general and came from my experience with charsets, keep in mind that I dont know how your app looks or how well charsets are treated in the other parts of the app. good luck
Alfred9847Author Commented:
Hi cdaugustin

Since, you are the only person who has tried to be of help, I will give you the points. My subscription is ending soon and I cannot wait much longer.

All the best,

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now