Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何在Firebase中存储HTML页面各个字段的不同副本?_Jquery_Html_Firebase_Firebase Realtime Database - Fatal编程技术网

Jquery 如何在Firebase中存储HTML页面各个字段的不同副本?

Jquery 如何在Firebase中存储HTML页面各个字段的不同副本?,jquery,html,firebase,firebase-realtime-database,Jquery,Html,Firebase,Firebase Realtime Database,我正在使用Firebase作为我的应用程序的实时数据库。在JavaScript文件中使用JQuery 这是Firebase中的my数据库结构 users |--- email: "pavan@gmail.com" |--- name: "pavan" 我能够在数据库中存储name和email字段的值。但是,对于每次提交,Firebase中以前的值都会被新值覆盖 我的问题是,如何在firebase中存储name和email字段值的不同副本而不覆盖以前的值? 这些是我申请书的摘录 Java

我正在使用Firebase作为我的应用程序的实时数据库。在JavaScript文件中使用JQuery

这是Firebase中的my数据库结构

users
  |--- email: "pavan@gmail.com"
  |--- name: "pavan"
我能够在数据库中存储
name
email
字段的值。但是,对于每次提交,Firebase中以前的值都会被新值覆盖

我的问题是,如何在firebase中存储
name
email
字段值的不同副本而不覆盖以前的值?

这些是我申请书的摘录

JavaScript文件:

$(document).ready(function () {

    // Submit Button 
    $('#submitBtn').click(function () {

        var inputNameValue = $('#inputName').val();
        var inputEmailValue = $('#inputEmail').val();

        // Get a reference to the database service
        var databaseRef = firebase.database().ref('users/');

        // Setting the input field values into the database
        databaseRef.set({
            name: inputNameValue,
            email: inputEmailValue
        });

        // Empties the fields after pushing the data into firebase
        $('#inputName').val('');
        $('#inputEmail').val('');
    });

});
HTML文件:

<body>
    <div class="mainDiv" align="right">
        <h1 align="left">Firebase Web App</h1>
        <br>
        <div align="left" class="form-group">
            <label for="inputName">Name:</label>
            <input type="text" class="form-control" id="inputName" placeholder="Enter your name">
        </div>
        <div align="left" class="form-group">
            <label for="inputEmail">Email:</label>
            <input type="text" class="form-control" id="inputEmail" placeholder="Enter your email">
        </div>
        <button id="submitBtn"><i class="fa fa-arrow-right" aria-hidden="true"></i></button>
    </div>

    <script src="https://www.gstatic.com/firebasejs/3.7.8/firebase.js"></script>
    <script src="firebase-init.js"></script>
    <script src="index.js"></script>
</body>

Firebase Web应用程序

姓名: 电邮:
您需要添加
push()
,以便在数据库中存储字段的不同副本。试试这个。这肯定会有用的

databaseRef.push().set({
  name: inputNameValue,
  email: inputEmailValue
});

uid
是Firebase身份验证系统使用的名称,即
。onAuthStateChanged
使用通常与
更新一起使用的uid填充(未设置)。因此,大多数应用程序的结构类似于
用户
,每个子应用程序都是一个uid密钥