Skip to content Skip to sidebar Skip to footer

Call Laravel Controler From An Ajax Request With Get / Put / Delete Method

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 th

Solution 1:

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

Solution 2:

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.

Post a Comment for "Call Laravel Controler From An Ajax Request With Get / Put / Delete Method"