jQuery Content Type Option
|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
jQuery Content Type OptionHello 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. |
|
|
Re: jQuery Content Type OptionI'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@...> Hello Everyone, |
| Free embeddable forum powered by Nabble | Forum Help |