How can I successfully pass the edu_id from an AJAX request to my Laravel controller?
Utilizing anchor tags
<a href="javascript:void(0);" onclick="showEditEducation(some_specific_id);" title=""><i class="la la-pencil"></i></a>
Implementation of Javascript function
function showEditEducation($edu_id)
{
console.log($edu_id);
$.ajax({
type: "POST",
url: "{{ route('show-edit-education', $user->id) }}",
data: {"education_id": edu_id,"_token": "{{ csrf_token() }}"},
datatype: 'json',
success: function (json) {
$("#showMe").html(json.html);
}
});
}
Laravel Controller handling the edit education form
public function showEditEducationForm(Request $request, $user_id)
{
$user = User::find($user_id);
$education_id = $request->input('education_id');
$applicantEducation = ApplicantEducation::find($education_id);
dd($applicantEducation);
}
The console.log output shows a correct number for "edu_id". However, there seems to be an issue with how ajax interprets it.