I'm currently trying to check if the response I'm getting is empty. Now what I think will work is below:
$.ajax({
type: 'GET',
url: '<%=Url.Action("FindTransaction", "Calls") %>',
data:
{ companyID: $('#CompanyDDL').val(),
storeID: storeNo,
tranDate: $('#TranDate').val(),
tranNum: $('#TranNum').val()
},
success: function (tData) {
if (tData == null) {
$('#tranNotFound').show("blind", options, 500);
} else {
$('#products').html('');
$('#SKUs').html('');
$('#price').html('');
for (var i = 0; i < tData.length; i++) {
$('#SKUs').append(!tData ? '' : tData[i].SKUN + '<br />');
$('#products').append(!tData ? '' : tData[i].DESCR + '<br />');
$('#price').append(!tData ? '' : tData[i].EXTP + '<br />');
}
$('#till').html(!tData ? '' : tData[0].TILL);
$('#tran').html(!tData ? '' : tData[0].TRAN);
$('#cashier').html(!tData ? '' : tData[0].CashierName);
$('#total').html(!tData ? '' : tData[0].TOTL);
$('#fullTransactionDetails').show("blind", options, 500);
}
}
});
I think what I'm doing will achieve what I'm aiming for however, I can't seem to find out as I'm having a second issue of tData[0] is undefined
and I'm trying to fetch data for something that I know will definately return an empty response, so as far as I'm concerned, it shouldn't even hit that part of the code.
I'm at a bit of a loss with this so any help is greatly appreciated.