jeudi 21 mai 2020

When I deploy the website, firebase database is not working?

When I deploy my website, the button that plus an email address from a form doesn't work. Here is the code ( I used the hex code for the session memory since I want to pull info from another page that they are redirected to after they click the button ):

> <!-- The core Firebase JS SDK is always required and must be listed
> first --> <script
> src="https://www.gstatic.com/firebasejs/7.9.1/firebase-app.js"></script>
> <script
> src="https://www.gstatic.com/firebasejs/7.9.1/firebase-database.js"></script>
> 
> <script type="text/javascript"
> src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
> 
> <!-- TODO: Add SDKs for Firebase products that you want to use
>      https://firebase.google.com/docs/web/setup#available-libraries -->
> 
> <script>   // Your web app's Firebase configuration   var
> firebaseConfig = {
>     apiKey: "AIzaSyAwGIIWffBD_p-S6kEn9pv8sqvkq_U9JnE",
>     authDomain: "bdpmedia-888b1.firebaseapp.com",
>     databaseURL: "https://bdpmedia-888b1.firebaseio.com",
>     projectId: "bdpmedia-888b1",
>     storageBucket: "bdpmedia-888b1.appspot.com",
>     messagingSenderId: "57430670642",
>     appId: "1:57430670642:web:d2a8a866e266c4d2ea2b2b"   };   // Initialize Firebase   firebase.initializeApp(firebaseConfig);
>     
>     //------
>     
>         String.prototype.hexEncode = function(){
>     var hex, i;
> 
>     var result = "";
>     for (i=0; i<this.length; i++) {
>         hex = this.charCodeAt(i).toString(16);
>         result += ("000"+hex).slice(-4);
>     }
> 
>     return result }
>     
>     //-----------------
>     
>     const eml = document.getElementById('info1');
>     
>     var rootRef = firebase.database().ref().child('users');
>     
>     $('#save_button').click(function(){
>         //dodavanje emaila i childa
>         rootRef.child(eml.value).set({
>             Email:$('#info1').val(),
>             Valedated:false
>             
>         });  //cuva u session storage
>         
>         var emlhex = eml.value.hexEncode();
>         console.log(emlhex);
>         
>         sessionStorage.setItem("email", emlhex);
>  
>         
>         
>     })
>         
>     
>      </script>



Aucun commentaire:

Enregistrer un commentaire