SHARE
TWEET

Untitled

a guest Jun 17th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $host = 'localhost';
  2. $dbUser = 'root';
  3. $dbPassword = '';
  4. $dbName = 'myDataBase';
  5.  
  6. $mysqli = new mysqli($host, $dbUser, $dbPassword, $dbName);
  7.      
  8. $tableName = "myTable";
  9. $result = $mysqli->query("SELECT * FROM " . $tableName);
  10.      
  11. $arr = [];
  12. while ($fila = $resultado->fetch_assoc()) {
  13.     array_push($row, $fila);
  14. }
  15.      
  16. print_r($arr);
  17. $mysqli->close();
  18.      
  19. <script>
  20. var xmlhttp = new XMLHttpRequest();
  21. xmlhttp.onreadystatechange = function() {
  22.   if (this.readyState == 4 && this.status == 200) {
  23.     //En este punto, cuando la llamada haya finalizado y si todo está bien deberías tener lo que devuelve tu php en this.responseText
  24.     let response = JSON.parse(this.responseText);
  25.     console.log("PHP Response: ", response);
  26.   }
  27. };
  28. xmlhttp.open("GET", "./db.php", true);
  29. xmlhttp.send();
  30. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top