Solved

jQuery.ajax handling returned Russian/Chinese HTML data

Posted on 2009-05-16
9
963 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
 

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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now