Felix Maxime Felix Maxime - 5 months ago 42
jQuery Question

AJAX post request not being processed in laravel

I have a "Like" feature on my laravel site. It works fine as a POST request, however I'd like to use AJAX for the request as to not have to reload the page. I gave it an attempt, however I haven't done much AJAX in the past, and I'm getting some errors.


<li data-value="{{$status->id}}" class="like">

Laravel route:

Route::get('/status/{statusId}/like', [
'uses' => '\CommendMe\Http\Controllers\StatusController@getLike',
'as' => 'status.like',
'middleware' => ['auth'],


$('.like').click(function() {
$likeValue = $(this).attr('data-value');
$token = $('meta[name=csrf-token]').attr("content");
type: "POST",
url: host + '/status/' + $likeValue + '/like',
data: {likeValue: $likeValue, _token:$token},
}).success(function (res){


This will return the error:

TypeError: $.ajax(...).success is not a function



I see why this wasn't working. My route was expecting a GET request, not a POST. D'oh!