Solution of Chinese garbled code when jQuery ajax method transmits Chinese

  • 2021-07-04 18:11:53
  • OfStack

This paper describes the solution of Chinese garbled code when jQuery ajax method transmits Chinese. Share it for your reference, as follows:

Using the ajax method of jQuery, Chinese garbled code appears when passing Chinese. According to the previous method, it is not good to modify ajaxSetting in jquery file

sajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded;charset=UTF-8",processData:true,async:true,xhr:function(){return new E.XMLHttpRequest}

It doesn't work well, even in

Add in Ajax

contentType: "application/x-www-form-urlencoded;charset=UTF-8",

It doesn't work either,

It was later discovered that there was no addition


type:'POST',

Just add it,

In addition, it is preferable to modify chartset and pagingEncoding to UTF-8 in jsp


<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

At the same time, in java code, under using 1


response.setCharacterEncoding("UTF-8");

For more readers interested in jQuery related content, please check the topics of this site: "Summary of Ajax Usage in jquery", "Summary of jQuery form Operation Skills", "Summary of jQuery Common Plug-ins and Usage", "Summary of jQuery Operation json Data Skills", "Summary of jQuery Extension Skills", "Summary of jQuery Drag Effects and Skills", "Summary of jQuery Table (table) Operation Skills", "Summary of jQuery Common Classic Special Effects", "Summary of jQuery Animation and Special Effects Usage" and "Summary of jquery

I hope this article is helpful to everyone's jQuery programming.


Related articles: