Level 25
whats the response the browser is giving you in the Network Tab?
looks like its returning some kind of php encoded array instead a right json response
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am getting json array for my each column at the backend but not getting the result i want. Array looks like this // Array array:1 [ "data" => "id%5B%5D=%2Bvalue.id%2B&attendance%5B%5D=Leave&id%5B%5D=%2Bvalue.id%2B&attendance%5B%5D=Present&id%5B%5D=%2Bvalue.id%2B&attendance%5B%5D=Present" ]
How i can receive the real values from this array.. Below is my ajax code
//Ajax
$(document).ready(function() { $(document).ready(function () {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
});
$('select[name="students_class_id"]').on('change', function() {
var classID = $(this).val();
if(classID) {
$.ajax({
url: '/myform/ajax/'+classID,
type: "GET",
dataType: "json",
success:function(data) {
var attendance = `<div class="form-group">
<select class="form-control" id="attendance" name="attendance[]">
<option>Present</option>
<option>Absent</option>
<option>Leave</option>
</select>
</div>`;
var markup = '';
markup += '<tr> <th>#</th> <th>Student ID</th> <th>Student Name</th> <th>Attendance</th> <tr>';
$.each(data, function(key, value) {
markup += '<tr> <td><input type="hidden" value="value.id" name="id[]">' + value.id + '</td> <td>' + value.student_id + '</td> <td>' + value.first_name+ ' ' + value.last_name + '</td> <td> ' + attendance + '</td> <tr>';
});
$('table[id="studentsData"]').html(markup);
$('body').on('click', '#save-btn', function(e){
e.preventDefault();
var data = $('#studentsData').find('select, input').serialize();
$.post('/students/attendance', {data: data}, function(response){
console.log(response);
});
});
}
});
}
});
});
</script>
Please or to participate in this conversation.