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

后端 未结 2 1800
我在风中等你
我在风中等你 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.

    0 讨论(0)
  • 2021-01-26 05:41

    The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers.

    Ref: http://api.jquery.com/jQuery.ajax/

    NOTE: You can able to find this errors using in Firefox Tools->Web Developer ->Error Console or CTRL+SHIFT+J

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