function message(id) {
layui.use('layer', function() {
var layer = layui.layer;
layer.msg('你确定删除么?', {
time : 2000, //2秒自动关闭
btn : [ '确定', '取消' ],
yes : function(index) {
console.log(id);
$.ajax({
url : "{:U('Goods/deletype')}",
data : {
'id' : id
},
type : "Post",
dataType : "json",
success : function(data) {
console.log(data);
layer.msg(data.msg);
location.reload(); //删除成功后再刷新
},
error : function(data) {
$.messager.alert('错误', data.msg);
}
});
layer.close(index);
}
});
});
}
U('Goods/deletype’
单引号里面的‘’即是地址,这里与requestmapping对应的地址一致即可!
更多推荐
layUI发起ajax请求
发布评论