Javascript 每次我都会看到我的布局被复制和一些奇怪的东西。我在控制台中看到的是,我在我的表格中有整个布局,但在我的代码中我没有这样的东西。我注意到的另一件事是,如果我删除了这个url,那么我的代码仍然在工作。我真的不知道控制台中ajax的场景背后发生了什么。我返回了学
Javascript 每次我都会看到我的布局被复制和一些奇怪的东西。我在控制台中看到的是,我在我的表格中有整个布局,但在我的代码中我没有这样的东西。我注意到的另一件事是,如果我删除了这个url,那么我的代码仍然在工作。我真的不知道控制台中ajax的场景背后发生了什么。我返回了学,javascript,jquery,laravel,laravel-blade,Javascript,Jquery,Laravel,Laravel Blade,每次我都会看到我的布局被复制和一些奇怪的东西。我在控制台中看到的是,我在我的表格中有整个布局,但在我的代码中我没有这样的东西。我注意到的另一件事是,如果我删除了这个url,那么我的代码仍然在工作。我真的不知道控制台中ajax的场景背后发生了什么。我返回了学生数据,这是需要的,但是当我将其应用于视图,然后复制我的整个页面布局。。我应用了你的代码,但结果是一样的,而且当我运行这个console.log(response)的时候也一样;然后在控制台中,我可以看到正确的表,我可以看到我需要从ajax中获
每次我都会看到我的布局被复制和一些奇怪的东西。我在控制台中看到的是,我在我的表格中有整个布局,但在我的代码中我没有这样的东西。我注意到的另一件事是,如果我删除了这个url,那么我的代码仍然在工作。我真的不知道控制台中ajax的场景背后发生了什么。我返回了学生数据,这是需要的,但是当我将其应用于视图,然后复制我的整个页面布局。。我应用了你的代码,但结果是一样的,而且当我运行这个console.log(response)的时候也一样;然后在控制台中,我可以看到正确的表,我可以看到我需要从ajax中获得的内容。在控制台中,我返回所需的学生数据,但当我将其应用于视图时,它会复制我的整个页面布局。。我应用了你的代码,但结果是一样的,而且当我运行这个console.log(response)的时候也一样;然后在控制台中,我可以看到正确的表格,我可以看到我需要的东西
<select>`enter code here`
@foreach(App\StudentsClass::all() as $class)
<option id="class{{$class->id}}" value="{{$class->id}}">{{$class->class_name}}</option>
@endforeach
</select>
<table id="studentsData" class="table table-striped table-bordered table-list-search">
<thead>
<tr>
<th>#</th>
<th>Student ID</th>
<th>Student Name</th>
<th>Attendance</th>
</tr>
</thead>
@foreach($students as $student)
<tbody>
<tr>
<th>{{$student->id}}</th>
<td>{{$student->student_id}}</td>
<td>{{$student->first_name}} {{$student->last_name}}</td>
<td>
<div class="form-group">
<select class="form-control" id="gender">
<option>Present</option>
<option>Absent</option>
<option>Leave</option>
</select>
</div>
</td>
</tr>
</tbody>
@endforeach
</table>
<a class="fas fa-folder-open btn btn-success float-right mb-4 mr-2"> Save</a>
</div>
<script>
$(document).ready(function () {
@foreach(App\StudentsClass::all() as $class)
$("#class{{$class->id}}").click(function () {
var classes = $("#class{{$class->id}}").val();
$.ajax({
url: '{{url('/students/attendance')}}',
type: "GET",
dataType: "html",
data: 'class_id=' + classes,
success:function(response) {
// console.log(response);
$('table[id=studentsData]').html(response);
}
});
});
@endforeach
});
<select id="class_select">
@foreach(App\StudentsClass::all() as $class)
<option value="{{$class->id}}">{{$class->class_name}}</option>
@endforeach
</select>
<script>
$(document).ready(function(){
$('#class_select').change(function(){
var class = $(this).val();
$.ajax({
url: '{{url('/students/attendance')}}',
type: "GET",
dataType: "html",
data: 'class_id=' + classes,
success:function(response) {
// console.log(response);
$('#studentsData').html(response);
}
});
});
});
</script>