Receive information on the home page

Asked

Viewed 24 times

0

I have a PHP file where I receive data saved in firebase I can read the data but I have to open a Mozilla Firefox console to be able to read this data. I wanted to know how to read or print this data without opening the console or present directly on the main page.

  • Please return the code that was in question earlier. As it is now it is difficult to help you and the question runs the risk of not being answered or even being closed because it is too wide.

  • Please reverse your changes. The code is critical so that users can understand and give a better solution to your problem.

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 the Document.getElementById() to display 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;
  });

Browser other questions tagged

You are not signed in. Login or sign up in order to post.