data.results在尝试对其执行操作之前,如何检查以下内容是否为空?
$.getJSON(myurl, function(data) {
// if data.results is not empty
// {
// console.log(data.results.size);
// }
});
Run Code Online (Sandbox Code Playgroud)
if (data != null && data.results != null && data.results.length > 0) {
// the array is not empty
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6405 次 |
| 最近记录: |