Solved

jQuery.ajax handling returned Russian/Chinese HTML data

Posted on 2009-05-16
9
968 Views
Last Modified: 2012-05-07
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">
$(document).ready(function(){
 
$.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()
		});
</script>

Open in new window

0
Comment
Question by:Alfred9847
  • 5
  • 4
9 Comments
 
LVL 5

Expert Comment

by:cdaugustin
ID: 24410410
0
 

Author Comment

by:Alfred9847
ID: 24410516
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.
0
 
LVL 5

Expert Comment

by:cdaugustin
ID: 24411829
hi,

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
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Alfred9847
ID: 24412477
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. :=)
0
 
LVL 5

Expert Comment

by:cdaugustin
ID: 24414564
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.
0
 
LVL 5

Expert Comment

by:cdaugustin
ID: 24414578
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.
0
 

Author Comment

by:Alfred9847
ID: 24415625
<< 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.
0
 
LVL 5

Accepted Solution

by:
cdaugustin earned 500 total points
ID: 24416414
if you sure its not transport related, then take a look at

http://simonwillison.net/2006/Dec/21/charset/

and subsequently at the  

http://jerakeen.org/test/unicode/

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
0
 

Author Comment

by:Alfred9847
ID: 24418937
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,

Alfred
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question