ajax传参问题,大神求解
怎么把查出来的数据得id用ajax发送给Controller层
引入jquery
$.ajax({
type: "post", // 使用post方法访问后台
dataType: "json", // 返回json格式的数据
url: "localhost/v1/user/get_user", // 要访问的后台controller地址
data: {"id":'id}, //要发送的数据,这个id就是你要传到后台的id
error: function(XMLHttpRequest, textStatus, errorThrown) { // 设置表单提交出错
alert(XMLHttpRequest.readyState + " " + textStatus + "哎呀出错了,请检查网络");
},
success: function(data){ //这个data是服务器返回的数据
alert(JSON.stringify(data));
}
});