splt之后数组为空?
$.getJSON(url, { 'id': zuid }, function (data) {
$.each(data, function (i, item) {
if (i == "name") { document.getElementById("cname").value = item; }
if (i == "id") { document.getElementById("cid").value = item; }
if (i == "mbno") { document.getElementById("cmbno").value = item; }
if (i == "department") { document.getElementById("cdep").value = item; }
if (i == "remark") { document.getElementById("cremark").value = item; }
if (i == "groupid") {
var strs = new Array();
strs = item.toString().split(',');
for (var iii in strs) {
alert(iii);
if (iii != "" || iii != null || iii != "0") {
var ccid = iii + "cn";
alert(ccid);
document.getElementById(ccid).checked = true;
}
}
}
});
});
groupid= ,70,69,56,
为什么alert出来的都是0,0cn。。囧,有大大知道原因啊
------解决方案-------------------- <script>
var str = "70,69,56,";
var array = str.split(',');
for(var i in array) {
alert(array[i]);
}
</script>