我正在使用API来获取要附加到DOM的值,在数组中,一些值返回null,在表中将它们留空.我的问题是可以返回一个字符串,表明"信息丢失"而不是返回空?
success: function(currency) {
// loop through currency
for (var i = 0; i < currency.length; i++) {
if (currency[i].currency == userCurrency) {
var $tr = $("<tr />");
$tr.append($("<td />").text(currency[i].volume));
$tr.append($("<td />").text(currency[i].latest_trade));
$tr.append($("<td />").text(currency[i].bid));
$tr.append($("<td />").text(currency[i].high));
$("#theTable tbody").append($tr);
}
}
}
});
});
});
Run Code Online (Sandbox Code Playgroud)