0
阿贾克斯网址与网站的网址我的Ajax代码的chnange变化Laravel阿贾克斯问题
$.ajax({
url:"ajax",
type:"post",
headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
success: function(data)
{
alert(1);
console.log(data);
},
error: function(data){
}
})
Route.php
Route::post('ajax',function(){
auth()->user()->unreadNotifications()->update(['read_at' => \Carbon\Carbon::now()]);
})->name('ajax');
如果网站的网址是
http://localhost/servay_project/surveys
代码如果网址变更的网址为
http://localhost/servay_project/surveys/55/questions
错误发生
http://localhost/servay_project/surveys/55/ajax 404 (Not Found)
你意味着每个URL都路由 –
是,U需要定义每一个网址路径。如果url是missong,你会得到404(Not Found)错误 – Muthu17