路由:
$router->get('getModifylog', SamProofingController::class.'@getModifylog'); //修改日志
控制器
public function getModifylog(Request $request){
$id = $request->notice_id;
try {
$data = ProofingNoticeVer::where(["notice_id"=>$id])->get()->toArray();
if ($data) {
return response()->json(['code' => 1,'msg' => '获取成功' , 'data' => $data ]);
}
return response()->json(['code' => 0,'msg' => '暂无数据' ]);
} catch (Exception $e) {
return response()->json(['code' => 0,'msg' => $e->getMessage()]);
}
}
function show_modify_log(e,notice_id)
{
$.ajax({
url: "/admin/samproofing/getModifylog",
type: "get",
data:{
'_token':LA.token,
'notice_id':notice_id,
},
dataType:'json',
success: function (res) {
show_view_log(res.data)
}
});
}
另一种:
路由: 加了个 name
$router->get('getModifylog', SamProofingController::class.'@getModifylog')->name('get_Modifylog'); //修改日志
控制器
public function getModifylog(Request $request){
$id = $request->notice_id;
try {
$data = ProofingNoticeVer::where(["notice_id"=>$id])->get()->toArray();
if ($data) {
return response()->json(['code' => 1,'msg' => '获取成功' , 'data' => $data ]);
}
return response()->json(['code' => 0,'msg' => '暂无数据' ]);
} catch (Exception $e) {
return response()->json(['code' => 0,'msg' => $e->getMessage()]);
}
}
show_modify_log不一样
function show_modify_log(e,notice_id)
{
$.get('{{ route('get_Modifylog') }}',{id : notice_id}, function (data) {
if (data.code == 100){
console.log(data.data);
}
else{
swal(data.msg);
}
});
}