Receive information on the homepage

0

I have a PHP file where I get data recorded in firebase I can read the data but I have to open a Mozilla Firefox console to be able to read this data. I would like to know how to read or print this data without opening the console or displaying directly on the main page.

    
asked by anonymous 26.02.2018 / 17:00

1 answer

0

You can create a unordered list in your HTML:

<form onsubmit = "return a();">
    <input type = "text" id = "name">
    <input type = "text" id = "message">
    <input type = "submit">

</form>

<ul id="dados">
</ul>

And use Document.getElementById() to show the data:

firebase.database().ref('SMS/').on('child_added', function(snapshot) {
      var resultado = snapshot.val();
      console.log(resultado);

      var lista = document.getElementById('dados');

      var linha = "<li>"+resultado.name+" : "+ resultado.message + "</li>";

      lista.innerHTML = lista.innerHTML + linha;
  });
    
26.02.2018 / 17:57