最新的Web开发教程
 

W3Data参考


完成W3Data API参考

功能 描述
w3DisplayData 在HTML中显示的数据
w3IncludeHTML 显示HTML在HTML
w3Http 从服务器读取数据

完成W3Data属性参考

属性 描述
{{}} 定义了显示数据
W3重复 定义了重复数据
W3-包括-HTML 定义了包括HTML

例子

w3DisplayData

<!DOCTYPE html>
<html>
<script src="http://www.w3ii.com/lib/w3data.js"></script>
<body>

<div id="id01">
{{firstName}} {{lastName}}
</div>

<script>
w3DisplayData("id01", {"firstName" : "John", "lastName" : "Doe"});
</script>

</body>
</html> 
试一试»

w3Http

<!DOCTYPE html>
<html>
<link rel="stylesheet" href="http://www.w3ii.com/lib/w3.css">
<script src="http://www.w3ii.com/lib/w3data.js"></script>
<body>

<table id="id01" class="w3-table w3-bordered w3-striped">
  <tr>
    <th>Customer</th>
    <th>City</th>
    <th>Country</th>
  </tr>
  <tr w3-repeat="customers">
    <td>{{CustomerName}}</td>
    <td>{{City}}</td>
    <td>{{Country}}</td>
  </tr>
</table>

<script>
w3Http("customers.php", function () {
  if (this.readyState == 4 && this.status == 200) {
    var myObject = JSON.parse(this.responseText);
    w3DisplayData("id01", myObject);
  }
});
</script>

</body>
</html> 
试一试»

w3IncludeHTML

<!DOCTYPE html>
<html>
<script src="http://www.w3ii.com/lib/w3data.js"></script>
<body>

<div w3-include-HTML="h1.html"></div>
<div w3-include-HTML="content.html"></div>

<script>
w3IncludeHTML();
</script>

</body>
<html>
试一试»