jquery前台向后台传递json数据,后台解析

var user = {checkOpinion:$('#checkOpinion').val()};
var aMenu = encodeURI(JSON.stringify(user));

$.ajax({
url: url,
type: 'post',
data:"checkOpinion=" + aMenu,
datatype: 'text',
contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
success: function (destination) {
$('#checkOpinion').val('');
query();

后台处理
String str = URLDecoder.decode(request.getParameter("checkOpinion"),"UTF-8");
JSONObject jb=new JSONObject();
String checkOpinion=(String)jb.fromObject(str).get("checkOpinion");
checkOpinion获得的就是前台传过来的值

相关文档
最新文档