0
にFirebaseとHTMLテーブル間のリアルタイム更新firebaseからコードを表示データの下
<html>
<head>
</head>
<body >
<table style="width:100%;width:100%;" id="ex-table">
<tr id="tr">
<th>Brand</th>
<th>Description</th>
<th>Item Code</th>
<th>Product Category</th>
</table>
<script src="https://www.gstatic.com/firebasejs/4.1.3/firebase.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyB5aqeEmEIB56IvRt4DL8RyOr0JX5Mw3HQ",
authDomain: "tp-firebase-fd827.firebaseapp.com",
databaseURL: "https://tp-firebase-fd827.firebaseio.com",
projectId: "tp-firebase-fd827",
storageBucket: "tp-firebase-fd827.appspot.com",
messagingSenderId: "191127646247"
};
firebase.initializeApp(config);
var database = firebase.database();
database.ref().once('value', function(snapshot){
if(snapshot.exists()){
var content = '';
snapshot.forEach(function(data){
var val = data.val();
content +='<tr>';
content += '<td>' + val.brand + '</td>';
\t \t \t \t content += '<td>' + val.description + '</td>';
\t \t \t \t content += '<td>' + val.item_code + '</td>';
\t \t \t \t content += '<td>' + val.prod_cat + '</td>';
content += '</tr>';
});
$('#ex-table').append(content);
}
});
</script>
</body>
</html>
。どのように私はリアルタイム更新を達成することができますか?それだけのことは私がする必要があります。 TYSM for future help
のthnx :) –