在这段代码中,我以 1、2、3、4、5 的顺序发送数据......但是当它将此数据添加到数据库时,它就像 1、4、5、3、2 或其他东西一样。
for(var i = 1; i<=childs;i++){
var u = $('#name'+i).val();
var inf = $('#info'+i).val();
var l = $('#location'+i).val();
var b = $('#birth'+i).val();
var d = $('#death'+i).val();
var formData = "mode=add&number="+i+"&to="+t;
if(u.length > 0){
formData += "&username="+u;
}else if(inf.length > 0){
formData += "&info="+inf;
}else if(l.length > 0){
formData += "&location="+l;
}else if(b.length > 0){
formData += "&birth"+b;
}else if(d.length > 0){
formData += "&death"+d;
}
$.getJSON("content/child.php", formData, function(json){
$.each(json, function(key, value){
console.log(value); // in div i wrote ar1, ar2, ar3, ar4, ar5... but in database it addess how he wants ar1, ar3, ar4, ar5, ar2 let's say
});
});
}
});