I'm new to laravel and I've been stuck for hours with this problem-""This request has no response data available"". I research some related issues but wasn't still able to find solutions.
I have an autocomplete search that displays the list of students within an <a>
tag that has a onclick
function to show modal with details of the selected student. The autocomplete search is working properly, when I clicked the <a>
tag, the modal pops up but doesn't display the selected student's details.
I'm using ajax to fetch student's details and display it on the modal. I checked the Network status and it says "This request has no response data available". How to fix this? any help is highly appreciated.
This is what my autocomplete search looks like, the user will then click on the selected student to open modal and display student's details.
//My route
Route::group(['middleware' => 'auth'], function(){
Route::get('violation_entry', ['as' => 'violation_entry', 'uses' => 'ViolationEntryController@index']);
Route::get('violation_entry/fetch', ['as' => 'violation_entry.fetch', 'uses' => 'ViolationEntryController@fetch']);
Route::get('violation_entry/form', ['as' => 'violation_entry.form', 'uses' => 'ViolationEntryController@form']);});
//(My ViolationEntryController@fetch Controller)
//this is the searched result that triggers the display of modal when clicked using onclick="violationForm()"
function foreach($data as $student){
$output .= '<div class="row">
<div class="col-lg-8 col-md-12 col-sm-12" >
<a href="#" onclick="violationForm()" id="'.$student->student_id.'" class="violationFormStudent list-group-item list-group-item-action d-flex justify-content-start text-decoration-none">
<div class="student_image_div mr-3">
<img class="student_img" src="../paper/img/students_images/default_student_image.jpg" alt="Student Image">
</div>
<div class="student_details_div">
<p class="student_name_txt">'.$student->last_name.', '.$student->first_name.'</p>
<p class="student_number_txt text-dark">'.$student->student_id.' <span class="text-muted"> | '.$student->course.'-'.$student->section.' | '.$student->school.' </span></p>
</div>
</a>
</div>
</div>
';
}
//(index.blade.php view)
//this is the ajax request to fetch student's details and show modal
<script>
function violationForm(){
var query = $(this).attr('id');
$.ajax({
url:"{{ route('violation_entry.form') }}",
method:"GET",
data:{query:query},
success:function(data){
$('#violationEntryForm').modal('show');
$('#studentDetails').html(data);
}
});
};
</script>
//(My ViolationEntryController@form Controller)
//get ajax request and fetch student's information
function form(Request $request)
{
if($request->get('query')){
$query = $request->get('query');
$student = Students::where('student_id', $query)->first();
$output ='
<div class="student_img_div_modal mr-4">
<img class="student_img_modal" src="../paper/img/students_images/default_student_image.jpg" alt="">
</div>
<div class="student_details_div_modal">
<p class="student_id_txt_modal">'.$student->student_id.'</p>
<p class="student_name_txt_modal">'.$student->first_name.' '.$student->last_name.'</p>
<p class="student_details_txt_modal">'.$student->course.'-'.$student->section.' | '.$student->school.'</p>
</div>
';
echo $output;
}
}
This is the expected output for my modal
And this is the Final output where it doesn't display student's information
Below are the screenshots of my Network Status
Why is this ""This request has no response data available"" showing?