페이지에서 목록을 선택하고 모든 선택 목록을 반복합니다. 값은 "default", "Excuses Absent"및 "Excused Late"입니다. 기본값은 기본적으로 "선택 ..."입니다. 나는 이것을 서버에 전달하거나 아무런 처리가 필요 없기 때문에 무의미하다.왜이 배열에 NULL 값을 가져 옵니까?
이 내 jQuery를 : 그것은이 경우, 3 번 배의 정확한 금액 내가 그것을 테스트 할 때마다 거짓 인쇄하기 때문에
attendSelect.each(function(k, v)
{
attendance = $(this).val();
if(attendance != "default")
{
console.log(attendance == "default");
students[k] =
{
lesson : $(this).attr('id'),
student_id : $(this).attr('name'),
attendance : attendance
};
}
});
이 작동합니다. 그러나 문제는 서버 측에 있습니다 (제 생각에는?). 변수를 출력 할 때 jQuery에서 기본값을 찾은 시간에 NULL이 NULL로 표시됩니다. 확실히, 나는 NULLs가없는 크기 3의 배열만을 가져야한다. 내가 널 (null)을받을 이유를 문 경우에도 입력하지 않는 경우
students = JSON.stringify(students)
if(attendSelect.length)//protect against submitting on past lessons
{
$.post('', { students : students, cid: cid }, function(response)
{
console.log(response);
});
}
가 이해가 안 : 이것은 내 AJAX이다
$students = json_decode($_POST['students'], true);
var_dump($students);
array(12) {
[0]=>
NULL
[1]=>
NULL
[2]=>
NULL
[3]=>
array(3) {
["lesson"]=>
string(9) "lesson[7]"
["student_id"]=>
string(12) "student[241]"
["attendance"]=>
string(14) "Excused Absent"
}
[4]=>
array(3) {
["lesson"]=>
string(9) "lesson[7]"
["student_id"]=>
string(12) "student[270]"
["attendance"]=>
string(12) "Excused Late"
}
[5]=>
NULL
[6]=>
NULL
[7]=>
NULL
[8]=>
NULL
[9]=>
NULL
[10]=>
NULL
[11]=>
array(3) {
["lesson"]=>
string(9) "lesson[9]"
["student_id"]=>
string(12) "student[317]"
["attendance"]=>
string(14) "Excused Absent"
}
}
:
이
는 PHP에서 무엇을 인쇄한다 jQuery에서.
로 분류됩니다. 감사 :) –