1/1 NotFoundHttpException In Controller.php Line 268: Controller Method Not Found. In Laravel 5

- 1 answer

I am trying to post some data into laravel controller using jquery ajax, but it shows error

"1/1 NotFoundHttpException in Controller.php line 268: Controller method not found."

and in console is throws

"NetworkError: 404 Not Found "

here is my code below:

in routes.php

Route::controller('contact', 'ContactController');
Route::post('searchDependency','[email protected]');


public function postSearchDependency(){


ajax into index.blade.php


    var total = $('input[class="ids"]:checkbox:checked').length;
    var ContactId=[];
    $('input[class="ids"]:checked').each(function() {
        type: 'POST',
        data: 'contactId: ContactId',
        url: '<?php echo URL::to('contact/searchDependency')?>',         
            success: function(contacts){                


i already posted data using ajax to different method of another controller successfully this way, i already tried the possible solutions, but don't know what happens in this case, please anyone helps me out.



Assuming that the routes.php file contains the line:

Route::controller('contact', 'ContactController');

and your ContactController has the following function defined:

public function postSearchDependency() {

Then this function would be called by a post request to the url contact/search-dependency instead of contact/searchDependency

This is due to transformation of CamelCase function names to more friendly and readable URL's when using Route::controller.

If you additionally define a direct route to your controller methode like:

Route::post('searchDependency','[email protected]');

This route gets called directly by searchDependency in the URL (without contact before).

You can always check your existing routes and urls by typing

php artisan route:list

in your terminal.