ajax 乱码

1. 在页面的中文变量前添加encodeURIComponent()

$.ajax({
type: "POST",
url: "",
data:{
   id:encodeURIComponent(id),
   type:encodeURIComponent(type)
},
success: function(msg){

}
});

2. java代码中需要解码

type = URLDecoder.decode(type, "UTF-8");

如果这样传过来还是乱码,那么请把页面代码改成encodeURIComponent(encodeURIComponent(type)),试试。

以上纯属个人观点。。。

原文地址:https://www.cnblogs.com/qlong8807/p/3699506.html