Ajax Laravel return view 500 Error

前端 未结 2 1487
暗喜
暗喜 2021-01-20 10:26

I am getting each slider value in slide (Jquery Ui Slider) via Ajax to my Controller.

The Slider + Ajax looks like this:

    $(\"#sliderNumCh\").slid         


        
相关标签:
2条回答
  • 2021-01-20 10:49

    Your controller method should look like this:

    public function editProductPost(Request $request)
    {
        return response()->json([
            'sliderValue' => $request->get('value')
        ]);
    }
    

    You shouldn't be returning a view to a ajax request.

    Your ajax success method should look like this (for example):

    // first arg is the data returned by the controller method
    success: function (response) {
        console.log(response);
    }
    

    and it should ouput something like this:

    {
        'sliderValue': 4
    }
    
    0 讨论(0)
  • 2021-01-20 11:05

    Your route is named as editProductPost but you are searching for editProduct

    0 讨论(0)
提交回复
热议问题