for some reason, i cannot set data to firebase realtime database.
the function works as intended, values are stored in the vars, and no error is presented...the data just won't upload to the firebase realtime database.
the js code:
$(document).ready(function(){
document.getElementById('submitEmplyee').onclick = function()
{
idNumberVal = document.getElementById('IDNum').value;
nameVal = document.getElementById('Name').value;
addressVal = document.getElementById('Address').value;
telephoneVal = document.getElementById('telephone').value;
//Ready();
firebase.database().ref('employe/' + nameVal).set({
EmplyeeID: idNumberVal,
NameOfEmp: nameVal,
AddressOfEmp: addressVal,
TelephoneOfEmp: telephoneVal
});
//alert("New HighScore !!!");
}
the sources:
<script src = "https://www.gstatic.com/firebasejs/8.2.4/firebase-app.js"></script>
<script src = "https://www.gstatic.com/firebasejs/8.2.4/firebase-auth.js"></script>
<script src = "https://www.gstatic.com/firebasejs/8.2.4/firebase-database.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="logic.js"></script>
full HTML Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>David Frucht CRUD app</title>
</head>
<body>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="container">
<h1>Emplyee Information</h1>
<button id="newEmployeBtn" class="btn btn-primary btn-block">New Emplyee</button><br /><br />
<form id="newForm">
<div class="form-group row">
<label for="IDNum" class="col-sm-2 col-form-label">ID Number</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="IDNum" placeholder="ID Number">
</div>
</div>
<div class="form-group row">
<label for="Name" class="col-sm-2 col-form-label">Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="Name" placeholder="Name">
</div>
</div>
<div class="form-group row">
<label for="Address" class="col-sm-2 col-form-label">Address</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="Address" placeholder="Address">
</div>
</div>
<div class="form-group row">
<label for="telephone" class="col-sm-2 col-form-label">Telephone Number</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="telephone" placeholder="Telephone Number">
</div>
</div>
<button id="submitEmplyee" type="submit" class="btn btn-primary">Add to DB</button>
</form>
<table id="emplyesTable" class="table table-bordered table-hover">
<thead>
<th>Emplyee ID</th>
<th>Name</th>
<th>Address</th>
<th>Telephone</th>
<!-- <th>DB ID</th>
<th>Controls</th>-->
</thead>
<tbody id="employeBody"></tbody>
</table>
</div>
<script src = "https://www.gstatic.com/firebasejs/8.2.4/firebase-app.js"></script>
<script src = "https://www.gstatic.com/firebasejs/8.2.4/firebase-auth.js"></script>
<script src = "https://www.gstatic.com/firebasejs/8.2.4/firebase-database.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="logic.js"></script>
</body>
question from:
https://stackoverflow.com/questions/65932710/jquery-can-not-set-data-to-firebase 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…