Hi there, I am facing an issue with calling code from an ajax request for getting the current time. I have set up an HTML file with a working clock in it, but when loading the text from $container1, the clock and date are not displaying on the page. Can anyone help me understand why this is happening? The text from container 1 is loading fine, so why is the current time and date clock not functioning properly?
Here is the code snippet of what I currently have in the HTML file from which the data is being fetched:
// JavaScript code to display current date and time
var mydate = new Date();
var year = mydate.getYear();
// ... (remaining script as per original source)
// Displaying the date and time on the webpage
document.getElementById('time').innerHTML = Time + " " + dayarray[day] + " " + montharray[month] + "/" + daym + "/" + year + " " + hours + ":" + minutes + ":" + s + " " + ampm;
document.getElementById('time2').innerHTML = Text + " " + dayarray[day];
}
// Loading content from container1 div
$('#container').load('C:/Program%20Files/TrueChem/Data/dashboard/src/Test.HTML #container1');
And here is the setup in the page where I want the content to be loaded:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
// Function to refresh the page after a certain interval
function refreshPage() {
// Code for refreshing the page
}
window.onload = function () {
setTimeout(refreshPage, 3000);
if (window.location.href.indexOf('page_y') != -1) {
var match = window.location.href.split('?')[1].split("&")[0].split("=");
document.getElementsByTagName("body")[0].scrollTop = match[1];
}
// Code for loading content from container1 div
{
$('#container').load('C:/Program%20Files/TrueChem/Data/dashboard/src/Test.HTML #container1');
}
}
</script>
<div id="container">