I am trying to make an incredibly simple ajax call, but it wont work. Here is the php side called by ajax( This returns the correct response )
<?php
$returnValue = '';
$allUploads = array_slice(scandir('./uploads'), 2);
$returnValue .= '<table>';
foreach ($allUploads as $upload) {
$returnValue .= '<tr><a href ="/uploads/' . $upload . '>' . $upload . '</a></tr>';
}
$returnValue .= '</table>';
echo($returnValue);
?>
And here is the javascript thats letting me down
<script>
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange =
function ()
{
if (this.readyState == 4 && this.status == 200)
{
alert(this.responseText);
document.getElementById("filedisplaytable").innerHTML = this.responseText;
}
};
xhttp.open("GET", "listuploads.php", true);
xhttp.send();
</script>
Worst thing about this is, that the alert statement is outputting exactly what I want to write:
<table>
<tr>
<a href ="/uploads/DSC001.jpg>DSC001.jpg</a></tr><tr><a href ="/uploads/DSC002.jpg>DSC002.jpg</a>
</tr>
<tr>
<a href ="/uploads/DSC003.jpg>DSC003.jpg</a>
</tr>
</table>
But when I write that into the div it writes the a hrefs 1st followed by an empty table...
Any help is greatly appreciated.... struggling to do such simple things really gets me down