Call laravel controler from an ajax request with get / put / delete method

后端 未结 2 1803
我在风中等你
我在风中等你 2021-01-26 04:56

I am having a javascript like this which will call two different controller in two diff situation .... Now the problem is it is one get method and one is destroy method ... when

2条回答
  •  滥情空心
    2021-01-26 05:35

    You are trying to access a javascript variable inside a php helper function will not work. I'm not sure what's passing id into that function, but if it's being passed into the view via PHP, then you should use {{ action('FollowsController@show', array($id)) }}

    If it's not being passed into the view, then you would have to use myUrl = '/follow/'+id and make sure you have routes for both GET and DELETE.

提交回复
热议问题