如何在FastAdmin中使用Ajax发送请求?

2021-01-24 11:12

阅读:1184

标签:layer   data   add   post   red   com   public   player   decode   

html页面:

js文件里添加以下代码:{field: ‘uid‘, title: __(‘解绑‘), table: table, buttons: [
{
name: ‘ajax‘,
text: __(‘解绑‘),
title: __(‘解绑‘),
classname: ‘btn btn-xs btn-success btn-magic btn-ajax‘,
icon: ‘fa fa-magic‘,
url: ‘player/player/unbundling?‘,
confirm: ‘确认是否要解绑‘,
success: function (data, ret) {
if(ret["msg"]["code"]==200){
Layer.alert("解绑"+ret["msg"]["msg"]);
}
else {
Layer.alert(‘‘+ret["msg"]["msg"]+‘‘);
}
},
error: function (data, ret) {
console.log(data, ret);
Layer.alert(ret.msg);
return false;
}
}
], operate:false, formatter: Table.api.formatter.buttons},

后台代码如下:
public function addRoomCardSave(){
$uid = $_POST["uid"];
$num = $_POST["num"];
$result = $this->commonFun($uid,$num);
if(!$result){
return $this->success("请求失败,服务器error");
}
else{
$res = json_decode($result,true);
return $this->success($res);
}
}

如何在FastAdmin中使用Ajax发送请求?

标签:layer   data   add   post   red   com   public   player   decode   

原文地址:https://www.cnblogs.com/xieqijiang/p/13255996.html


评论


亲,登录后才可以留言!