上傳到主機后,當我嘗試通過 ajax 更改資料庫中的某些內容時收到此訊息,因為我知道它在 localhost 中運行良好
"message": "CSRF token mismatch.",
"exception": "Symfony\\Component\\HttpKernel\\Exception\\HttpException",
"file": "/hermes/bosnacweb08/bosnacweb08ab/b1283/ipg.nmedcure47094/proxima/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php",
這是我的 ajax 代碼
$.ajax({
url: '{{ url('appointment') }}/update_status_doctor/' appointment_id,
type: "PATCH",
data: {
'_token': "{{ csrf_token() }}",
'status': status,
'doctor': doctor,
},
這是路線
Route::patch('/appointment/update_status_doctor/{id}', [AppointmentController::class, 'update_status_doctor'])->middleware('auth');
我所做的但不起作用的解決方案是放置 ob_start(); 在 index.php 中公開
uj5u.com熱心網友回復:
我想您需要將 ajax 代碼更改為以下內容
$.ajax({
url: '{!! url('appointment') !!}/update_status_doctor/' appointment_id,
type: "POST",
data: {
'_token': "{{ csrf_token() }}",
'_method': "PATCH",
'status': status,
'doctor': doctor,
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/397079.html
標籤:javascript php mysql 阿贾克斯 拉拉维尔
上一篇:如何檢索從RequestEntity.post(String,Object...)獲得的RequestEntity的URL
下一篇:在列印之前檢查Ajax成功回應
