I am trying to display either daily or monthly webcam images depending on the status of a toggle switch. The default is Daily when the page loads and displays today's images as it should when the page first loads. The problem is when the button is toggled, the Monthly images do not load or neither do the Daily images. I am making an AJAX call to load the different images. All this works except the loading of the images when the button is toggled. There are 2 different php pages for Daily or Monthly images. The array contains the image and the file date.
Here is my code. I am not getting any errors on the console and the network status is 200. A test string on both pages does display when toggling the button.
This is the php page displaying what I am trying to return
Thank you in advance for looking.
Here is my code. I am not getting any errors on the console and the network status is 200. A test string on both pages does display when toggling the button.
HTML:
<div id="cam_images">
<?php include_once 'get_images_day.php';?>
</div>
JavaScript:
<script>
function showWx(toggle) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("cam_images").innerHTML = this.responseText;
}
};
if (toggle === 'month') {
var url="get_images_month.php";
}
else {
var url="get_images_day.php";
}
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
</script>
This is the php page displaying what I am trying to return
PHP:
...build image array
//echo "Day Images Test"; // for testing
for ($i = 0; $i < count($images); $i++) {
echo "<div class='mySlides'>";
echo "<img src='camgallery/".$images[$i][0]. "'>";
echo "</div>";
}
echo "<a class='prev' onclick=\"plusSlides(-1)\">❮</a>";
echo "<a class='next' onclick=\"plusSlides(1)\">❯</a>";
echo " <div class='caption-container'>";
echo "<span id='caption'></span>";
echo "</div>";
echo "<div class='row'>";
for ($i = 0; $i < count($images); $i++) {
echo "<div class='column'>";
echo "<img class='demo cursor' src='camgallery/'".$images[$i][0]. "' style='width:100%' alt='".$images[$i][1]."''>";
echo "</div>";
}
Thank you in advance for looking.