zoukankan      html  css  js  c++  java
  • 动态渲染数据到表格中


    <script>
    //兼容方案
    // var xhr=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHTTP');


    var xhr = new XMLHttpRequest();
    xhr.open('GET', 'test.php');
    xhr.send();
    xhr.onreadystatechange = function () {
    if (this.readyState !== 4) return;
    var res = JSON.parse(this.responseText);
    // res => 服务端返回的数据
    var data = res.data;
    for (var i = 0; i < data.length; i++) {
    // 先创建行
    // 再创建列
    // 再将列添加到行
    // 再将行添加到tbody
    // console.log(data[i])
    var tr = document.createElement('tr');
    tr.innerHTML = '<td>' + data[i].id + '</td><td></td><td></td><td></td><td></td><td></td>'
    }
    }
    </script>
  • 相关阅读:
    IO库 8.5
    IO库 8.4
    标准模板库——IO库
    IO库 8.3
    IO库 8.2
    IO库 8.1
    CF 599D Spongebob and Squares(数学)
    Django入门学习(一)
    hdu 5733
    uva 11210
  • 原文地址:https://www.cnblogs.com/lujieting/p/10291277.html
Copyright © 2011-2022 走看看