I have a function which returns results (or not). The problem is when it does not return any value I get in the console the message
cannot read prope
You could just return a deferred, that way the done()
callback won't generate errors, and you can choose to resolve it or not
if(items.length > 0){
return $.ajax({
url: 'response.php?type=getDelivery',
type: 'POST',
data: {content: items}
});
}else{
var def = new $.Deferred();
def.resolve(false);
return def;
}
FIDDLE