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!
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.
try .setRequestHeader( 'content-type', 'application/x-www-form-urlencoded;charset=UTF-8' );
"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
精彩评论