How to solve Chinese garbled characters submitted by JQuery ajaxSubmit, jqueryajaxsubmit
The average user is
jQuery(form).ajaxSubmit({ url: "ajaxsub.aspx?abc=test",type: "post", dataType: "json", success: data});
Analysis: JQuery's AJAX submission will encode the data to be submitted and use encodeURIComponent to process the data in js. Therefore, both Firefox and IE submit data are consistent and are UTF-8-encoded data.
Check the Header and find that the Content-Type in Entity is different.
In Firefox, Content-Type specifies the UTF-8 character set.
In IE, no character set is specified,
Obviously, by default, the character encoding submitted asynchronously by AJAX should be consistent with that of the webpage itself. That is to say, when the Server side does not find the character set specified by the display, using gb2312 to decode the data (but the data has been coded by the UTF-8 before submission), That's why garbled characters occur in IE, and in Firefox, when the browser submits AJAX data, the charset display is specified, causing the Server to use the UTF-8 to decode the data (correct decoding ).
Check JQuery's AJAX Tool Function Description and find that there is a specified content-type parameter in options.
Therefore, you must specify the encoding type during submission.
contentType: "application/x-www-form-urlencoded; charset=utf-8",
That is
jQuery(form).ajaxSubmit({ url: "ajaxsub.aspx?abc=test", type: "post", dataType: "json", contentType: "application/x-www-form-urlencoded; charset=utf-8", success: data});
The above content will share with you how to solve the Chinese Garbled text submitted by JQuery ajaxSubmit. I hope it will be helpful to you.