Ajax Poll - How to retrieve new score to the correct span id
I want to create an AJAX poll to rate comments. In each comment you can either thumbs up, or thumbs down by clicking on an image. I achieved that part. However, I don't know how to update the score with AJAX in the correct span.
If you don't know what the value of $comment_id is ahead of time, then the onclick event will have to pass this id to the AJAX code so that the AJAX code can send back the returned score to the proper place.
I don't know how to pass the id to AJAX with the onclick event. I'm not very good with JS.
Show the onclick event you're using now to invoke the AJAX process. Also show the HTML around where the onclick event is so that I can see the relationship between where the onclick is and where the response container is.
OK, since $comment_id is also placed in the value for the INPUT element, then you can code your inline event attribute as follows to pass that to your function as an argument:
Code:
onclick="ajaxFunction(this.value)"
You'll just need to extract it for use in the getElementById method to obtain addressability to the response span.
Bookmarks