1
votes

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!

3
so how are things going? It's been a while. - Horia Dragomir

3 Answers

0
votes

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.

0
votes

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

0
votes

"application/x-www-form-urlencoded" and utf-8 cannot be used together.I too had "application/x-www-form-urlencoded", While accepting request in doPost method of servlet try request.setCharacterEncoding("UTF-8"); worked for me for multilingual characters after much searching