我正在尝试从html向Firebase写入一些数据。此过程有效;但是,有时我会收到503错误,有时还会收到“弃用”通知,而且,当我单击“提交”时,有时需要很长时间才能完成提交。是用正确的方式写的还是过程不正确的?
<script src="https://www.gstatic.com/firebasejs/6.2.4/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/6.2.4/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-database.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.1.2/firebase.js"></script>
<script>
var firebaseConfig = {
apiKey: "AIzaSy333333CoLQMOkxO3rYLiywsrib6nCOWFBZv_xI0",
authDomain: "dem33333otestingdata.firebaseapp.com",
databaseURL: "https://dem33333otestingdata.firebaseio.com",
storageBucket:"dem33333otestingdata.appspot.com",
};
firebase.initializeApp(firebaseConfig);
function writeData() {
firebase.database().ref("User").set({
name:document.getElementById("nameField").value,
age:document.getElementById("ageField").value
});
}
</script>
<h1>User Databse</h1>
<input type="text" placeholder="name" id="nameField">
<input type="text" placeholder="age" id="ageField">
<button onclick = "writeData()">Submit</button>
答案 0 :(得分:0)
请尝试从HTML文件中删除此script
标记,因为该标记已被弃用
<script src="https://www.gstatic.com/firebasejs/4.1.2/firebase.js"></script>
并替换以下
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-database.js"></script>
具有最新的CDN
<script src="https://www.gstatic.com/firebasejs/6.2.4/firebase-database.js"></script>