/* Fetch發送請求 get*/
var page=1;
var pageSize=5;
var totalPage=0;
fetch(`/user/queryUser?page=${page}&pageSize=${pageSize}`, {
headers: {
'Content-Type': 'application/json; charset=UTF-8'
},
}).then(res => res.json()).then(res => {
console.log(res);
totalPage=(Math.ceil(res.total/pageSize));
var html = template("userTpl", res);
console.log(html);
$("#userBox").html(html);
}).catch(err => {
console.log(err);
})
//Fetch請求 post
var data={
id:id,
isDelete:isDelete
}
fetch("/user/updateUser",{
headers: {
'Content-Type': 'application/json; charset=UTF-8'
},
method:"post",
body:JSON.stringify(data),
}).then(res=>res.json()).then(res=>{
console.log(res);
if(res.success){
location.reload();
}else{
if(res.error){
alert(res.message);
}
}
})