以前台传送id为例子:
前台代码:
function deletebyid(id){
var id=id;
alert(id);
$.ajax({
type:"post",
url:"delete.do",
data: {"id":id},
dataType: "json",
success:function(result){
layer.msg(result),setTimeout(50000);
}
});
}
如果传送的是表单:
function add() {
$.ajax({
type : "post",
url : "add.do",
data:$("#addForm").serialize(),
success : function(result) {
if (result == "Success") {
layer.msg(result), setTimeout(function() {
window.location = "showlist.do";
}, 150);
} else {
layer.msg(result), setTimeout(function() {
window.location = "showlist.do";
}, 150);
}
}
});
}
后台取数据代码:
String id=req.getParameter("id");