success: function (data) { // request 取得成功获得回复後实行 let list_html = ""; $.each(data, function (index, item) { console.log(item.item_id); console.log(item.star); list_html = `
${item.name}
` }); $("ul.task_list").html(list_html); },
AJAX 从伺服驱动器获得JSON列阵 串连在HTML里 想要知道为何麽我的each循坏只能抓数据库索引数值1的json列阵放进去??
这也是教师的案例 我还是看不出来区别在哪儿求得
success: function(data){ // request 取得成功获得回复後实行 console.log(data); let list_html = ""; $.each(data, function(index, item){ list_html = "
"; list_html = "
"; list_html = ""; list_html = ""; list_html = ""; list_html = ""; list_html = ""; list_html = ""; list_html = ""; list_html = ""; list_html = ""; list_html = "= 1 ? " -on" : "") "" data-star="1">"; list_html = "= 2 ? " -on" : "") "" data-star="2">"; list_html = "= 3 ? " -on" : "") "" data-star="3">"; list_html = "= 4 ? " -on" : "") "" data-star="4">"; list_html = "= 5 ? " -on" : "") "" data-star="5">"; list_html = ""; list_html = "" item.name "
"; list_html = ""; list_html = ""; list_html = ""; list_html = ""; list_html = ""; list_html = ""; list_html = ""; list_html = ""; list_html = "
"; }); $("ul.task_list").html(list_html); },[ { "item_id": 899, "name": "一二三", "star": 0, "sort": 1 }, { "item_id": 118, "name": "四五六", "star": 0, "sort": 1 }]