[英]Laravel 5.1 ajax simple URL route showing Not found error (404)
<script type="text/javascript">
function variants(master_id)
{
$.ajax({
type: "GET",
url: "getVariants"+'/'+master_id,
success: function(){
}
});
}
</script>
This is the script that I have defined and kept is as simple as possible. 这是我定义并保持的脚本尽可能简单。
The route is this and it still shows me 404 not found error. 路线是这个,它仍然显示404 not found错误。
Route::get('getVariants/{master_id}','Retailer\ProductController@getVariants');
将完整的网址路径http://example.com/getVariants/master_id添加到ajax调用
<meta name="_token" content="{{ csrf_token() }}"/>
headers: {'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')}
尝试
url: "/getVariants"+'/'+master_id,
尝试以下方法:
Route::any('getVariants/{master_id}','Retailer\ProductController@getVariants');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.