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 http://translate.google.com/translate_t 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

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

cdaugustinConnect With a Mentor Commented:
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:
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 http://www.yunqa.de/delphi/doku.php/products/converters/index 

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.
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.


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

http://translate.google.com/translate_t 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.
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,

All Courses

From novice to tech pro — start learning today.