jQuery - Ajax post result in html displaying in wrong position
Posted
by Sev
on Stack Overflow
See other posts from Stack Overflow
or by Sev
Published on 2010-05-04T09:34:31Z
Indexed on
2010/05/04
9:38 UTC
Read the original article
Hit count: 232
I have a site with user posted threads that get voted on (up or down), and a vote count is displayed next to each thread.
The voting up and down process is being done through jQuery/Ajax, and using something like this:
$.ajax({
url: 'vote.php',
success: function(data) {
$('.result').html(data);
}
});
the html of the vote count is being updated (.result being the class of the div that holds the vote count number)
Also, the threads are being sorted first by vote count descending, and then alphabetically.
I'm having a problem with the ajax updating the HTML vote count in real time, i have a hunch that the issue is due to the fact that the order of the threads are changing when the vote count is being updated, but I'm not certain.
I know the database is being updated, and when I refresh the page, it's also being updated correctly, but I'm not seeing the real-time behavior that I expect from jQuery/Ajax.
What might be the problem?
© Stack Overflow or respective owner