<script type="text/javascript">
function variants(master_id)
{
$.ajax({
type: "GET",
url: "getVariants"+'/'+master_id,
success: function(){
}
});
}
</script>
这是我定义并保留的脚本,尽可能简单。
路线是这样的,它仍然向我显示 404 未找到错误。
Route::get('getVariants/{master_id}','Retailer'ProductController@getVariants');
将完整的 url 路径 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');