dongpo5207 2019-04-11 19:30
浏览 295

{message:“”,exception:“Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException”,...}

I'm a newbie in laravel. I want to add a product using ajax method but I'm getting this error, in the console: POST 404 NOT FOUND. In the network, I'm getting this error message:

{message: "", exception: "Symfony\Component\HttpKernel\Exception\NotFoundHttpException",…}
exception: "Symfony\Component\HttpKernel\Exception\NotFoundHttpException"
file: "C:\Usersolan\Desktop\Laravel Tutorial\Fims\vendor\laravel\framework\src\Illuminate\Routing\RouteCollection.php"
line: 179
message: ""
trace: [{,…}, {,…}, {,…}, {,…}, {,…},…]

Here is my ajax code:

<script>
$(document).ready(function(){
    // alert("working");
    $("#btn").click(function(){
        var prodName = $("#prodName").val();
        var rate = $("#rate").val();
        var beginningQuantity = $("#beginningQuantity").val();
        var token = $("#token").val();

        $.ajax({
            type: "POST",
            data: "prodName=" + prodName + "&rate=" + rate + "&beginningQuantity=" + beginningQuantity + "&_token" + token,
            url: "<?php echo url('/saveProduct') ?>",
            success: function(data){
                console.log(data);
            }
        });
    });
});
</script>

here's the line 179 codes

<input type="hidden" value="{{csrf_token()}}" id="token">

here's the controller code

public function saveProduct(Request $request){
    return $request;
}

here's the route

Route::get('/adminIndex',"adminIndexController@count");
Route::get('/adminInventory',"adminInventoryController@count");
  • 写回答

2条回答 默认 最新

  • duanfan9859 2019-04-11 19:36
    关注

    Ok so I'm not sure if this has anything to do with it, but it seems as though you may have incorrectly typed it into your question, but you have written:

    $.ajax({
        type: "POST",
        data: "prodName=" + prodName + "&rate=" + rate + "&beginningQuantity=" + beginningQuantity + "&_token" + token,
        url: "<?php echo url('/saveProduct') ?>",
        succes: function(data){
            console.log(data);
        }
    });
    

    Is it meant to say success: instead of succes:?

    评论

报告相同问题?

悬赏问题

  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 github训练的模型参数无法下载
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案
  • ¥50 winform中使用edge的Kiosk模式
  • ¥15 关于#python#的问题:功能监听网页
  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题