Ajax Laravel return view 500 Error

前端 未结 2 1488
暗喜
暗喜 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
    }
    

提交回复
热议问题