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!
This is my routes
Route::post('contact_request','HomeController@getContactUsForm');
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.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community