I am trying to hit a post route in Laravel and it is giving a 500 error. I tried a different route and it works.. Please note that we have recently added ssl to the site.
the error message in Chrome Dev tools
jquery.js:4 POST https://murgency.com/saveRequestInfo 500 (Internal Server Error)
The HTML code :-
<div class="form-group text-right">
<a href="" type="button" class="btn-sm-arrowhead" id="dwnBrochure"
title="Download Brochure">Download Brochure</a>
</div>
jquery code :-
$('#dwnBrochure').click(function (e) {
var text_name = $('#txt_name').val();
var countryCode = $('#countryCode option:selected').text();
var text_number = $('#txt_number').val();
var text_email = $('#txt_email').val();
var package = $('#packagetype').val();
var type = "agingParents";
var url = '/saveRequestInfo';
var data = {
name: text_name,
email: text_email,
countryCode: countryCode,
phone: text_number,
package: package,
type: type
};
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url: url,
data: data,
type: 'POST',
datatype: 'JSON',
success: function (response) {
if (response.status === true) {
window.location = "https://murgency.com/home-health-plans/senior/brochure-success";
}
else {
alert('failure');
}
},
error: function (response) {
}
});
e.preventDefault();
});
routes.php
Route::post('saveRequestInfo', 'ServicesController@saveRequestInfo');
ServicesController code:-
public function saveRequestInfo(Request $request)
{
$data = $request->input();
$object = new ParseObject("MedicalRequest");
$object->set('name', $data['name']);
$object->set('email', $data['email']);
$object->set('package', $data['package']);
$object->set('phone', $data['countryCode'] . $data['phone']);
$object->set('type', $data['type']);
try
{
$object->save();
$status = true;
} catch (ParseException $ex)
{
$status = false;
}
$this->sendBrochureEmail($data['email'], $data['name']);
return Response::json(['status' => $status, 'message' => $data['name']]);
}