当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Retrieving data from Firebase database

问题描述:

I am completely new to Firebase and I have got the data to save in the Firebase database, but I am not being able to retrieve it and show up in a table. My code is below. Any help will be greatly appreciated.

Here is the image of the firebase database:

Javascript:

/*jslint plusplus: true*/

var rootRef = firebase.database().ref().child("users");

rootRef.on("child_added", snap => {

var medname = snap.child("MedName").val();

var end = snap.child("End").val();

var start = snap.child("Start").val();

var type = snap.child("Type").val();

var Description = snap.child("description").val();

$("demo").append("<tr><td>" + medname + "</td><td>" + end +

"</td><td>" + start + "</td><td>" + type +

"</td><td>" + Description +

"</td><td><button>Remove</button></td></tr>");

}

Html:

<!-------------------------------------- Table -------------------------------------------->

<table>

<thead>

<tr>

<td>MedName</td>

<td>End</td>

<td>Start</td>

<td>Type</td>

<td>Description</td>

</tr>

</thead>

<tbody id=demo>

</tbody>

</table>

网友答案:

first of all correct the error in the script. write #demo instead of demo in jquery . Hope this will help you completely

分享给朋友:
您可能感兴趣的文章:
随机阅读: