GET提交:
function del(id){
var _href ="/group_del?id="+id;
layer.open({
shade:false,
content:'确定删除?',
btn: ['确定', '取消'],
yes:function (index) {
$.ajax({
url: _href,
type:"get",
success:function (info) {
if (info.code ===1) {
setTimeout(function () {
location.href ="/group";
}, 1000);
}
layer.msg(info.msg);
}
});
layer.close(index);
}
});
}

POST:
function add() {
var name=$("input[name='name']").val();
var token=$('meta[name="csrf-token"]').attr('content');
var url="/group_add";
$.ajax({
url:url,
dataType:'json',
type:'post',
data: {'name':name,"_token":token},
async:false,
success:function (info) {
if (info.code ===1) {
setTimeout(function () {
location.href ="/group";
}, 1000);
}
layer.msg(info.msg);
},error:function (e) {
//console.log(e.status)
}
});
}

php

网友评论