Hello, I am new to ajax but need to solve a what seems to me a tricky situation.
I receive some live soccer matches data through some xml files that are put in a server. One of the attributes of the xml items is "status" which when a match is currently playing displays the minutes. I build a grid with div-s while reading the xml, and in some particular div I call the function that triggers the ajax, which should return the result to the div which called it.
The php code:
Code:
<div class="status" id="<?php echo $match_id ?>">
<script type="text/javascript"> getStatus('<?php echo $match_id ?>'); </script>
</div>
The Javascript code:
Code:
<script language="javascript" type="text/javascript">
xmlhttp = new XMLHttpRequest();
function getStatus(id)
{
xmlhttp.onreadystatechange =
function()
{
if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
{ document.getElementById(id).innerHTML = xmlhttp.responseText;
} else
{ document.getElementById(id).innerHTML = "...";
}
}
xmlhttp.open("GET", "functions/returnStatus.php?match_id="+id, true);
xmlhttp.send();
}
</script>
For some reason (that i don't know) The ajax returns "..." to all divs except the last one, where it returns the proper result.
Please help, at least with any idea where to start searching for solutions.
Thanks in advance!