Alright so pretty basic, here are the pieces of code I have, basically it's supposed to updated my table "comments" on the "like" column. My problem is situated in the javascript while trying to submit the result.
SPAN which contains a link to submit:
<span id="like<?=$i?>"><a href="javascript:void()" onClick="likeComment(<?=$row[commentid]?>, <?=$i?>)" />Like</a> (<?=$row[like]?>)</span>
Basically commentid is the actual comment ID, and $i is the comment # (so when I submit the +Like it will actually update the right SPAN tag.
After that, I have my AJAX which will post it to my PHP file:
<script type="text/javascript">
function likeComment(id, no)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("like"+no).innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","like_game.php?id="+id"&no="+no,true);
xmlhttp.send();
}
</script>
Basically it is supposed to submit the comment ID and the comment SPAN ID, so then my PHP file will return
<span id="like<?=$number?>"><font color="#009900">You like this</font> (<?=$row[like] + 1?>)</span>
(I didnt include the PHP, my issue isnt stiuated in there.
I don't know what the problem is, but it wont work. When I do it with just one ID, it does work so in my opinion, there is a problem with either
xmlhttp.open("GET","like_game.php?id="+id"&no="+no,true);
or
document.getElementById("like"+no).innerHTML=xmlhttp.responseText;
So bascially it is supposed to submit comment ID 60 for example, it is situated in the SPAN ID'd 5, so when it submits it, it should be supposed to return in the right ID.
Any help is appreciated, because I'm clueless here.