Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $host = 'localhost';
- $dbUser = 'root';
- $dbPassword = '';
- $dbName = 'myDataBase';
- $mysqli = new mysqli($host, $dbUser, $dbPassword, $dbName);
- $tableName = "myTable";
- $result = $mysqli->query("SELECT * FROM " . $tableName);
- $arr = [];
- while ($fila = $resultado->fetch_assoc()) {
- array_push($row, $fila);
- }
- print_r($arr);
- $mysqli->close();
- <script>
- var xmlhttp = new XMLHttpRequest();
- xmlhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- //En este punto, cuando la llamada haya finalizado y si todo está bien deberías tener lo que devuelve tu php en this.responseText
- let response = JSON.parse(this.responseText);
- console.log("PHP Response: ", response);
- }
- };
- xmlhttp.open("GET", "./db.php", true);
- xmlhttp.send();
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement