【发布时间】:2012-05-22 04:29:54
【问题描述】:
我正在尝试在 ajax 调用中处理完整的函数。如果值未定义,我想将 var 转换为空字符串。否则,我想将值捕获到字符串数组中。
问题是我正在输入 if 语句,即使将相关变量的值记录为未定义也是如此。我在这里错过了什么?
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
if(typeof $(this).attr("ows_Products") !== undefined) {
console.log($(this).attr("ows_Products"));
arr = $(this).attr("ows_Products").split(',');
}
else {
arr = "";
}
});
}
【问题讨论】:
-
看看这个之前的问题:stackoverflow.com/questions/776950/…
-
@web_bod 在比较 == 和 === 方面看起来更多,这意味着 null == undefined = true,而 null === undefined = false
标签: javascript jquery ajax types