61,128
社区成员




<script src="https://code.jquery.com/jquery-1.11.0.js"></script>
<table id="tb"></table>
<button onclick="go()">本地模拟</button>
<script>
$.ajax({
url: '请求api的地址',
data: {id:'xxx'}, // 请求的参数
dataType: 'json', // 返回数据的类型
success: function (res) {
// api返回的数据
console.log(res)
go(res.data)
}
})
var data = ['111','222','333','444']
function go(obj) {
var html = []
list = obj || data
list.forEach((item, index) => {
html.push('<tr><td>第'+(index+1)+'行</td><td>'+item+'</td></tr>')
})
$('#tb').html(html.join(''))
}
</script>