How to reload a div using php & ajax
Confused about ajax story
$images=array("img01.png", "img02.png", "img03.png");
<div id="imgBox">
<?php
echo "<img onclick='reload()' src=\"img/".$images[0]."\">";
echo "<img onclick='reload()' src=\"img/".$images[1]."\">";
echo "<img onclick='reload()' src=\"img/".$images[2]."\">"; ?>
</div>
onclick - I want to shuffle $images on server side, and then rewrite #imgBox
<script type="text/javascript">
function reload(){
var content=document.getElementById("imgBox").innerHTML;
var url="shuffle.php";
postRequest(url);
}
function postRequest(){
var xmlHttp;
if (window.XMLHttpRequest) {
var xmlHttp = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttp.open('POST', strURL, true);
} // I know - something is wrong here.
</script>
shuffle.php:
$content = shuffle($images);
echo "<img onclick='reload()' src=\"img/".$images[0]."\">";
echo "<img onclick='reload()' src=\"img/".$images[1]."\">";
echo "<img onclick='reload()' src=\"img/".$images[2]."\">";
very strange - nothing happend :))
Please help.