我有代码创建一个div类型表,然后填充某些数据。在集合中,我需要创建一个下拉选择,该选择由第二个数据集填充,由当前JSON数据设置。但是,我不知道为什么,<select>
只是没有显示 - 即使我将html输出转储到控制台,它也不存在。我已经确认数据集包含信息,它是有效的JSON数据,但它不起作用!
这是我的整个代码块:
function GetData() {
if ($('#orderno').val().length > 0) {
$('#results').html('<img src="../../../images/loading.gif" style="margin:90px auto auto auto; display:block;" />')
$.getJSON("getdata.asp?orderno="+$('#orderno').val(), function(data){
var len = data.length;
if (len == 0) {
alert("None")
} else {
html = ' <div class="div-table"><div class="div-table-row">'
html = html + '<div class="div-table-col td1">Sales Order</div>'
html = html + '<div class="div-table-col td2">Part #</div><div class="div-table-col td3">Part Desc</div>'
html = html + '<div class="div-table-col td4">Desp. Date</div><div class="div-table-col td5">Num.</div>'
html = html + '<div class="div-table-col td6">Loc</div>'
html = html + '</div></div>'
for (var i = 0; i< len; i++) {
html = html + '<div class="div-table-row" val="'+data[i].salesorder+'">'
html = html + '<div class="div-table-col td1">'+data[i].salesorder+'</div>'
html = html + '<div class="div-table-col td2">'+data[i].productcode+'</div>'
html = html + '<div class="div-table-col td3">'+data[i].stockdesc+'</div>'
html = html + '<div class="div-table-col td4">'+data[i].reqdate+'</div>'
html = html + '<div class="div-table-col td5"><input id="despnum" type="number" min="0" max="'+data[i].qty+'" value="'+data[i].qty+'" disabled /></div>'
$.getJSON("getloc.asp?part="+data[i].productcode, function(data){
html = html + '<div class="div-table-col td6"><select id="location">'
var len2 = data.length;
for (var j = 0; j< len2; j++) {
console.log(data[j].binno)
html = html + '<option value="'+data[j].binno+'" >'+data[j].binno+'</option>'
}
html = html + '</select>'
})
html = html + '</div>'
}
html = html + '</div>'
$('#results').html(html);
}
});
}
}
我错过了什么?