PinoyStackOverflower
PinoyStackOverflower

Reputation: 5302

Laravel 5 jQuery ajax post throws a Controller method not found error

This is my routes.php

Route::controller('user','UserController');

My javascript code which is in my blade file

  jQuery.ajax({
            type:"POST",
            url:"/user/login-from-fb/",
            data:{
                data:data,
                _token: "<?php echo csrf_token(); ?>"
            },
            success:function(data){

            }
        });

In my UserController.php

public function postLoginFromFb(){
    $data = \Input::all();
    var_dump($data);
    die;
}

This is my code but looks like i am always getting an error. This is the error:

Sorry, the page you are looking for could not be found.

NotFoundHttpException in Controller.php line 259: Controller method not found.

Any ideas why this is happening?

Your help will be greatly appreciated!

Thanks! :)

Upvotes: 1

Views: 1171

Answers (1)

Imtiaz Pabel
Imtiaz Pabel

Reputation: 5443

try using this types url

<?php echo URL::to('user/login-from-fb') ?>

Upvotes: 2

Related Questions