仿照SQL取出flag==true
的物件
success: function(res) { console.log(res); const showHospital = res.filter(function(element) { return element.flag == true }) }
完整版
function his_data() { $.ajax({ url: '<?php echo site_url('HIS/GetHIS'); ?>', method: 'get', dataType: 'json', success: function(res) { console.log(res); const showHospital = res.filter(function(element) { return element.flag == true }) console.log(showHospital) renderHeaderRow(showHospital); //渲染标题列的内容(2间医院) renderRowOptions(showHospital); //渲染标题列的下拉式选单(之后医院会增加) changeHospital(showHospital); //标题列下拉之后改变医院的标题 Object.keys(showHospital[0]).forEach(element => { if (element != 'id' && element != 'attribute' && element != 'title') renderFixedItems(showHospital, element); }); renderColValues(showHospital); // addItem(res); //增加项目栏位 // changeItem(res); //依据项目栏位改变内容 }, error: function(err) { console.log(err) }, }); } ```