[英]How to use laravel route in ajax url
This route marks notifications as read, using ajax 该路由使用ajax将通知标记为已读
Route::get('markAsRead', function() {
Auth::user()->unreadNotifications->markAsRead();
return Redirect()->back();
});
function markNotificationAsRead()
{
$.get('markAsRead');
}
This works from the root directory: 这在根目录下有效:
http://localhost/markAsRead
but when i want to access this route from 但是当我想从这里访问这条路线时
http://localhost/user/markAsRead
it does not work, so how Can I use the laravel route and make it work? 它不起作用,那么如何使用laravel路线并使之起作用?
Without beginning slashes, the URL is relative to the current page. 该URL相对于当前页面,不带斜杠。 To make it absolute, you want to add a slash before it:
为了使其绝对,您想在其前面添加一个斜杠:
function markNotificationAsRead()
{
$.get('/markAsRead');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.