checkdata['attendance_batch'] = [
{user_id_c: 'abcda', ispresent: 0},
{user_id_c: 'abxcda', ispresent: 2},
{user_id_c: 'abctda', ispresent: 1}
]
Я хочу, чтобы мой массив в вышеуказанном формате в JavaScriptДобавить двумерный массив в JavaScript
МОЙ HTML:
<label for='flip'>" + entry["name"] + "</label><div id='switch'><select name='user_id_c' id='flip2b' iduser='"+entry["id"]+"' data-role='slider'><option value='1'>Present</option><option value='0'>Absent</option></select>
$("#frmattendance").submit(function(event) {
event.preventDefault();
$form = $(this);
var a = {};
var paramString = [];
$($form).find(':input').each(function() {
//console.log($(this).attr('name'));
if ($(this).val() == 'Mark') {
}
else {
a[{user_id_c: $(this).attr('iduser'), ispresent: $(this).val()}];
// console.log(a[$(this).attr('name')]);
}
});
var $sessiondata = sessionStorage.sessionid;
$.ajax
({
type: "POST",
url: saverecordurl + 'pcc_attendance',
dataType: 'json',
async: false,
// session_id: $sessiondata,
//json object to sent to the authentication url
data: {checkdata: a, session_id: $sessiondata},
success: function(response) {
//console.log(response);
if (response.id !== null)
{
alert("You have successfully marked the attendance");
$.mobile.changePage("#eventdetails", {
transition: "slide",
reverse: true,
changeHash: true
});
}
},
error: function(result) {
$.mobile.changePage("#one", {
transition: "slide",
reverse: false,
changeHash: true
});
}
})
});
Может ли кто-нибудь помочь мне в формате, я делаю ошибку?
Что это HTML делает там? – amphetamachine
Получение данных из html и формирование массива – vini
Это массив объектов, а не двумерный массив. Я не совсем уверен, что вы спрашиваете. Когда вы говорите, что хотите «отправить» эти данные, вы имеете в виду как в POST? –