Laravel 5.3 : POST 使用 Ajax 的请求总是通过 jquery.min.js 在控制台中返回错误 404

Laravel 5.3 : POST request using Ajax always returning Error 404 in console by jquery.min.js

我正在使用 Laravel 5.3 并尝试使用 Ajax - Jquery 发出 POST 请求。 对于我的一生,我无法找到我的代码中有什么错误。

如果有帮助,我正在尝试使用管理面板中的 ajax 在我的 table 中添加新的大学详细信息。我已经确定我正在发出 POST 请求并且我的 routes/web.php 有一个路由方法 POST 来接收请求。

我的 master.blade.php 有以下行:

<meta name="csrf-token" content=" {{ csrf_token() }} ">
<script type="text/javascript" src="{{URL('js/jquery.min.js')}}"></script> //jQuery v2.1.4

在我的 view 中,我有以下 内部 javascript 脚本。我使用 @section@yield 概念将其呈现为一个。

我的 settings/home.blade.php 看起来像这样:

@section('scripts')
 <script type="text/javascript">
 function addCollSubmit()
 {

   $.ajaxSetup({

    headers:{
        'X-CSRF-TOKEN' : $('meta[name="csrf-token"]').attr('content')
    }

    });


    var formData = new Array();
    for(var i=0 ; i< coll_no; i++)
    {
       var id = "input[name=coll_name_"+i+"]";
       var temp = $(id).val();
       formData.push(temp);
    }

     $.ajax(
    {
        type:'POST',
        headers : { 
            'X-CSRF-TOKEN' : $('meta[name="csrf-token"]').attr('content')
         },
        url:'/admin/settings/addcollege',
        data:formData,
        success:function(data)
        {
            console.log(data);
            $("#reveal-content").html(data);
        },
        error: function(data)
        {
            console.log(data);
        }
    });

   }
  </script>
 @endsection

我的 settings/home.blade.php 中的 form 部分看起来像:

<form method="POST" name="addCollegeForm" action="">
    {{ csrf_field() }}
    <table id="addCollTable">
     <tr>
        <td><input type="text" name="coll_name_0" placeholder="Enter College Name" /></td>
        <td><a class="button primary" onclick="oneMoreColl()" href="#"><i class="fi-plus"></i></a></td>
     </tr>
    </table>
    <table>
     <tr>
        <td colspan="2"><hr/></td>
     </tr>
     <tr>
        <td colspan="2" align="center">                         
        <a href="#addCollSubmit" onclick="addCollSubmit()" class="button success" >Submit</button></td>
     </tr>
    </table>
</form>

我的 routes/web.php 有以下行来接收 POST 请求:

Route::post('admin/settings/addcollege','SettingsController@postIndex');

postIndex() 确实有一个函数定义来将大学详细信息存储在 table.

每次我发出请求时,它都会在我的开发者工具-控制台中生成以下内容:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost/admin/settings/addcollege 

试试下面的方法url

 url:"{{url('/admin/settings/addcollege')}}",