Ajax的使用(此处为表单序列化方式)
$.ajax({
type: 'post',
data: $('#newPriorityForm').serialize(),
dataType: 'json',
contentType: "application/x-www-form-urlencoded;charset=utf-8",
url: url,
async: false,
success: function (returnMeg) {
// 成功
},
error: functon(returnMeg) {
// ajax响应失败
}
});
后台传参
//后台输出-ajax返回值
out = response.getWriter();
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> returnMessg = new HashMap<String, Object>();
out.print(mapper.writeValueAsString(returnMessg));
// mapper.writeValueAsString用于将对象转换成json