I have a getjson
which logs successfully if I give correct data.value, if I give invalid data.value it shows an empty array[]
on browser, how can I identify json returns an empty array []
using my getjson code, I have tried below code but not work, if I give invalid data.value. Need your help.
$.getJSON("http://xxx.xx.xx/mobapp/api/get-pli-details?id=" + data.value, function (result) {
console.log('here ' + result[0].email);
if (result[0] === null) {
popup("<h3>M-Elec</h3>Invalid PLI ID");
} else {
email = result[0].email;
userType = result[0].utype;
name = result[0].name;
}
});