Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

jQuery.ajax handling returned Russian/Chinese HTML data

Posted on 2009-05-16
9
Medium Priority
?
981 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…

704 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