Support the ongoing development of Laravel.io →
Views Forms Validation
Last updated 2 years ago.
0

How is your "routes.php" file setup? Can you post it? Mind that you are sending a POST request, so with this controller your route should be something like this:

Route::post('contact_request', array('as' => 'contact_request', 'uses' => 'HomeController@test_contact'));

Or in case you registered the controller in the route like this:

Route::controller('home', 'HomeController');

Then your controller method should contain the request verb:

public function postContactRequest()
{  
    // your code
}

In this case, your url would be "contact-request" instead of contact_request, as Laravel already parses it.

Cheers!

Last updated 9 years ago.
0

This is my routes

Route::post('contact_request','HomeController@getContactUsForm');
0

Taking your routes.php, this is what you should have in your controller HomeController.

class HomeController extends BaseController {

    /// your other code and stuff...

    public function getContactUsForm() { 
        if(Request::ajax()){
            // return 1;
            echo "yes";
            die();
        }else{
            // return 0;    
            echo "no";
            die();
        }
    }
}

Also, take a look at your javascript. Check your browser console (using the developer tools) for errors.

On a side note, use relative path in an AJAX url, if your route is mywebsite.com/myroute, then your AJAX url should be just "myroute" instead of using the full qualified domain. More info here.

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

shiva shiva Joined 24 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.