views:

190

answers:

2

Hey,

I need to be able to specify using Javascript how to post a form that contains both the enctype as "application/x-www-form-urlencoded" and charset as "charset=UTF-8" in the Content-Type header. Any ideas?

I have a aForm object of type Form.

Thanks!

A: 

Last I checked, you simply can't rely on being told the charset of a form submit. Most sites either assume the charset (hopefully UTF-8 on modern sites) or they pass it in a separate query parameter.

Assuming that the charset will be something in particular isn't as crazy as it sounds. Every browser in common use will use the same encoding for submitting a form as the page that contained the form. So if you send the HTML page containing the form in UTF-8, you can pretty safely assume the submission will also be in UTF-8.

Laurence Gonsalves
Thanks for your response. The problem is that when I'm sending it to the server, I send it as 'application/x-www-form-urlencoded', but on the server side, it gets changed to 'text/plain', so I need to ensure on the server side it stays as 'application/x-www-form-urlencoded' and the charset is UTF-8.
Bob K
By the way, I'm using a form object.Thanks!
Bob K
A: 

try .setRequestHeader( 'content-type', 'application/x-www-form-urlencoded;charset=UTF-8' );

Horia Dragomir