最新の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>
»それを自分で試してみてください