简体   繁体   中英

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.

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');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM