Forum Moderators: open
I am try to update cell table using AJAX.
I have a table, with 5row x 5column.
The main problem here is updating the cell of table without refreshing the entire page and the table too.
I was thinking maybe I can put a trigger in each cell(td) to update data in the DIV of the cell randomly every 5 second.
but, what is the suitable trigger in each cell?. I dont know any trigger that may use with td except onmouse* trigger. I think not suitable to use onmouse(over/up/down) trigger to implement this one.
If anybody has any ideas or suggestions I would greatly appreciate it.
once again, thanks alot...:)
Best Regards,
denny
this is the example of my recent script :
<html>
<head>
<title>Ajax at work</title>
<script language = "javascript">
var XMLHttpRequestObject = false;
if (window.XMLHttpRequest) {
XMLHttpRequestObject = new XMLHttpRequest();
} else if (window.ActiveXObject) {
XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
}
function getData(dataSource, divID)
{
if(XMLHttpRequestObject) {
var obj = document.getElementById(divID);
XMLHttpRequestObject.open("GET", dataSource);
XMLHttpRequestObject.onreadystatechange = function()
{
if (XMLHttpRequestObject.readyState == 4 &&
XMLHttpRequestObject.status == 200) {
obj.innerHTML = XMLHttpRequestObject.responseText;
}
}
XMLHttpRequestObject.send(null);
}
}
</script>
</head>
<body>
<H1>Actually, this script only reload when mouseover.
does any function for td reload automaticly?</H1>
<table border=1>
<tr>
<td>data state</td>
<td onMouseOver="getData('status_now.php','div1')"><div id="div1">NULL</div></td>
<td onMouseOver="getData('status_now.php','div2')"><div id="div2">NULL</div></td>
<td onMouseOver="getData('status_now.php','div3')"><div id="div3">NULL</div></td>
</tr>
</table>
</body>
</html>
Don't you need to update *all* of the data in one go? ie. with a getAllData(dataSource) function? Otherwise could you not end up with a mixture of old data and new?
Yeah, I don't think it's suitable to use a mouse event in this case(?) The user may only mouseover one or two cells, and the third cell may have changed - or the user may not use the mouse at all!?