With the same form, ie and firefox sent different forms, why?
I have a form, and if I only fill in English characters, everything is OK, but if I tried to fill in some Chinese characters, then problem happens:
If fill in the form in chrome or firefox, then it sent following request:
/docsearch/documents/site/test/documentLibrary/?filter=path&开发者_开发知识库;filterData=%2F&size=50&pos=1&prop_cm_name=%E4%B8%AD%E5%9B%BD HTTP/1.1
If fill in the form in IE, then it sent following request: /doclib/docsearch/documents/site/test/documentLibrary/?filter=path&filterData=%2F&size=50&pos=1&prop_cm_name=\326\320\271\372 HTTP/1.1
As you can see, same Chinese characters can have different encoding within IE and firefox. Can someone tell me how to make IE send the same requests as firefox/chrome ?
EDIT form:
<form action="" enctype="application/json" accept-charset="utf-8" method="post" id="template_x002e_toolbar_x002e_documentlibrary-form" forms-runtime="listening" onsubmit="return false;">
<div class="form-fields" id="template_x002e_toolbar_x002e_documentlibrary-form-fields">
<div class="form-field">
<label for="template_x002e_toolbar_x002e_documentlibrary_prop_cm_name">Name:</label>
<input type="text" title="Name" value="" tabindex="0" name="prop_cm_name" id="template_x002e_toolbar_x002e_documentlibrary_prop_cm_name">
</div>
</form>
It seems that IE treat those characters as Unicode, but not UTF8 as per the parameter in form?
You may need to either remove the enctype
attribute from the form
element, or choose one of the following values for it:
- application/x-www-form-urlencoded
- multipart/form-data
- text/plain
The value you're using, application/json
, might be causing the difference you're seeing, as different browsers may handle an unknown value of the enctype
attribute differently.
See here for more info.
精彩评论