I am trying to send an ajax post request in my page, but I'm getting an error in console.
POST http://local.bazaar.com/testimonials/submit 500 (Internal Server Error)
Routes.php
Route::post('/testimonials/submit','TestimonialsController@savetesti');
Ajax.js
$("#submitTestimonial").click(function() {
$.ajax({
url: '/testimonials/submit',
method: 'POST',
success: function(data) {
alert(data);
die;
}
})
return false;
});
TestimonialsController.php
<?php
namespace App\Http\Controllers;
use Input;
use Request;
class TestimonialsController extends Controller
{
/**
* Perform validations on user data
* Hash Password
* Create
* @return Response
*/
public function savetesti()
{
// Getting all post data
print_r("success");
}
}
?>
viewPage->
<div class="testimonialForm">
<form action="#" method="POST">
<div class="testimonialFormTitle">Write A Testimonials</div>
<a class="closeTestimonialBtn"></a>
<p><input type="text" placeholder="Your Name" id="tname" name="name" class="inputTxt placeholder"></p>
<p><input type="text" placeholder="Your Email" id="temail" name="email" class="inputTxt placeholder"></p>
<p><textarea placeholder="Testimonial" cols="50" rows="6" id="tmessage" name="message" class="inputTxtArea placeholder"></textarea></p>
<a class="greyBtn" id="submitTestimonial" href="#">Submit</a>
</form>
</div>