var array = '这是需要传递给后台的中文数据'
//只需要在ajax中的data里利用js的encodeURI()方法把数据转换成中文的编码就可以了
$.ajax({
type: "GET",
url: "/ask/subQuestion",
dataType: 'json',
data: {
array:encodeURI(array)
},
success: function (res) {
}
});
然后后台在接受数据的时候用decodeURI()方法解码一下就OK了。
URLDecoder.decode(value, "utf-8");
URLEncoder.encode(value, "utf-8");
更多内容请访问:IT源点
注意:本文归作者所有,未经作者允许,不得转载