I'm currently learning some jquery and javascript, I'm currently experimenting with a lot of stuff for our intranet systems, more or so converting some monitoring applications to web based applications.
One such Application involves having a menu list that changes background color dependent on activity, what I have done for this is loading a php page that generates the required status of each block and outputs it unto a list type format.
menu.php output
<ul>
<a href="index.php?id=1"><li class="green">Menu 1</li></a>
<a href="index.php?id=2"><li class="blue">Menu 2</li></a>
</ul>
php code changes id and the class, based on the status of data on the specific Menu, now using jquery's setInterval function, I autorefresh the divs containing the menu on my index.php to change the background color of the links, these links btw refreshes the data on div table.
index.php
$(document).ready(function() {
$.ajaxSetup({ cache: false });
setInterval(function() {
$('menu').load('menu.php');
}, 10000);
});
// ]]></script>
<body>
<div id="menu>
Menu list Generated here
</div>
<div id="table">
Selected data
</div>
</body>
what im trying to do now is I want to also refresh the data of the table div, by implementing ajax, and utilizing a .load on click (from menu.php) and loading an table.php using something like the code below to avoid refreshing the whole page.
<a id="click" href="#">click</a>
<script>
$(function() {
$("#click").click(function(evt) {
$("#table").div().load("table.php")
evt.preventDefault();
})
})
</script>
and it seems it is not working this time, from what I am seeing maybe it is not possible for the link on menu.php, to update the div on my index.php which is #table. hence my question
or maybe I'm doing this all wrong, any insights on what would be a better approach maybe?