I created this small script, from what I have learned about Ajax + Javascript so far.
I am running this in Chrome btw, so XMLHttpRequest(); should be working
PHP,
$conn = new PDO('mysql:host=localhost; dbname=test', 'root', '')
$stmt = $conn->query("SELECT text FROM ajax");
foreach($stmt as $each){
?>
Ajax,
<script type='text/javascript'>
var request = new XMLHttpRequest();
request.open('GET', <?php echo $each['text']; ?>, false);
request.send();
console.log(request);
</script>
<?php } ?>
Now, in database test where tbl name is ajax I have rows id & text, in which text has three filled-in rows, but the ajax code is not showing me anything. It is not echoing anything at all, let alone update instantly, when I am adding texts in my rows. What am I doing wrong?