I'm struggling to understand why I keep encountering the 'Unexpected end of JSON input' error when attempting to stringify an object array and passing it to an ajax call.
$(document).on("click", "#frmcomplist_cmdPrint", function(){
let complist = [];
let testlist = [];
let testnum = 0;
for(x = 1; x < rowCount; x++){
thisuser = $('#username'+x).html();
thiscomputer = $('#compname' +x).html();
if(thisuser != '' || thiscomputer != ''){
complist.push({
user: thisuser,
computer: thiscomputer
});
}
}
jQuery.ajax({
type: "POST",
url: 'reports//complist_print.php',
dataType: 'json',
data: {functionname: 'computer_list', JSONList: JSON.stringify(complist)},
success: function (obj, textstatus){
if (!(obj.error == '')){
jAlert(obj.error, 0 + 48, 'error', false);
} else {
}
},
error: function (xhr, status, error){
//alert(xhr.responseText);
jAlert(error, 0 + 16, "error", false);
},
complete: function (xhr, status) {
// dumps error/result
console.log(xhr.responseText);
}
});
});