HighDots Forums  

jQuery Content Type Option

jQuery jQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. jQuery is designed to change the way that you write JavaScript.


Discuss jQuery Content Type Option in the jQuery forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
webdawg
 
Posts: n/a

Default jQuery Content Type Option - 11-06-2009 , 03:59 PM






Hello Everyone,

I just joined your Group and hope to find a guru that can answer this
question.

Preface: I needed to serialize a form and POST it with jQuery AJAX.
I setup the content type for "ISO-8859-1" because that was a
requirement in this case. I set the option in jQuery and on the
server. Well, no matter what I did jQuery always serialized in
"UTF-8". After a lot of pain and suffering I found the solution to
use UTF_Decode on the server side. There is JavaScript function and
PHP function. The JavaScript can "runat server" to support ASP
and .NET as well.

Question: We have customers that will need to use Chinese Char
sets. This decode solution will not always be viable. Why does
jQuery ignore the Content Type I set on the client side? It seems
like this problem would not exist if jQuery simply encoded everything
the way the programmer asks. Is there a way to get jQuery to POST
in the encoding I want, such as simplified Chinese (e.g. gb18030).

I understand someone will likely tell me that I should use UTF-8 for
absolutely everything. But I would still like to know why jQuery's
content type option doesn't work. If that would work it would save a
lot of people a lot of trouble.

Reply With Quote
  #2  
Old   
Michel Belleville
 
Posts: n/a

Default Re: [jQuery] jQuery Content Type Option - 11-06-2009 , 07:20 PM






I'm really not sure about this, I never tried to get jQuery to send iso
chars myself, but I stumbled upon this on the ajax doc (
http://docs.jquery.com/Ajax/jQuery.ajax#options) :

scriptCharset String
Only for requests with 'jsonp' or 'script' dataType and GET type. Forces the
request to be interpreted as a certain charset. Only needed for charset
differences between the remote and local content.

Where I'm unsure is how you interpret the "Only for requests with 'jsonp' or
'script' dataType and GET type". It may mean it's only for GET requests with
jsonp or script dataType, or that it's only for jsonp for dataType, or GET
requests with script dataType. I'm inclined to guess it's the first since
you're sending a POST and you're not getting it in the propre charset. As
for the reason behind this I can only speculate there might be a browser
issue of some sort, but that's all I have here.

Hope it helps.

Michel Belleville


2009/11/6 webdawg <info (AT) smartweber (DOT) com>

Quote:
Hello Everyone,

I just joined your Group and hope to find a guru that can answer this
question.

Preface: I needed to serialize a form and POST it with jQuery AJAX.
I setup the content type for "ISO-8859-1" because that was a
requirement in this case. I set the option in jQuery and on the
server. Well, no matter what I did jQuery always serialized in
"UTF-8". After a lot of pain and suffering I found the solution to
use UTF_Decode on the server side. There is JavaScript function and
PHP function. The JavaScript can "runat server" to support ASP
and .NET as well.

Question: We have customers that will need to use Chinese Char
sets. This decode solution will not always be viable. Why does
jQuery ignore the Content Type I set on the client side? It seems
like this problem would not exist if jQuery simply encoded everything
the way the programmer asks. Is there a way to get jQuery to POST
in the encoding I want, such as simplified Chinese (e.g. gb18030).

I understand someone will likely tell me that I should use UTF-8 for
absolutely everything. But I would still like to know why jQuery's
content type option doesn't work. If that would work it would save a
lot of people a lot of trouble.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.