jQuery请求数据三步走
1.页面渲染
<div id="wo">你好!</div>
2.引入jQuery文件
下面展示一些 内联代码片
。
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
3.发送get请求
$.get("https://locally.uieee.com/categories",
function (resp) {
for (let i = 0; i < resp.length; i++) {
let txt1="<h1>"+resp[i].id+"</h1>";
let txt2="<h2>"+resp[i].name+"</h2>";
let txt3="<img src='"+resp[i].icon+"'>";
$("#wo").append(txt1,txt2,txt3);
}
},
"json"
);