Skip to main content
added 42 characters in body
Source Link
Sally CJ
  • 39.9k
  • 2
  • 26
  • 48

[EDIT] Provided better replacements.

Try this:

In template.php, replace:

echo '<div id="vote_counter">'. $votes.'</div><br>';

..with:

echo '<div id="vote_counter" class="vote_counterid="vote_counter-' . $post->ID . '">''" class="vote_counter">'. $votes.'</div><br>';

In voteme.js, replace:

jQuery("#vote_counter").html(response.vote_count);

..with:

jQuery(".vote_counter"#vote_counter-" + post_id).html(response.vote_count);

You should also declare post_id and nonce as local variables; i.e.:

var post_id = $(this).attr("data-post_id"),
  nonce = $(this).attr("data-nonce");

Hope that helps.

Try this:

In template.php, replace:

echo '<div id="vote_counter">'. $votes.'</div><br>';

..with:

echo '<div id="vote_counter" class="vote_counter-' . $post->ID . '">'. $votes.'</div><br>';

In voteme.js, replace:

jQuery("#vote_counter").html(response.vote_count);

..with:

jQuery(".vote_counter-" + post_id).html(response.vote_count);

You should also declare post_id and nonce as local variables; i.e.:

var post_id = $(this).attr("data-post_id"),
  nonce = $(this).attr("data-nonce");

Hope that helps.

[EDIT] Provided better replacements.

Try this:

In template.php, replace:

echo '<div id="vote_counter">'. $votes.'</div><br>';

..with:

echo '<div id="vote_counter-' . $post->ID . '" class="vote_counter">'. $votes.'</div><br>';

In voteme.js, replace:

jQuery("#vote_counter").html(response.vote_count);

..with:

jQuery("#vote_counter-" + post_id).html(response.vote_count);

You should also declare post_id and nonce as local variables; i.e.:

var post_id = $(this).attr("data-post_id"),
  nonce = $(this).attr("data-nonce");

Hope that helps.

Source Link
Sally CJ
  • 39.9k
  • 2
  • 26
  • 48

Try this:

In template.php, replace:

echo '<div id="vote_counter">'. $votes.'</div><br>';

..with:

echo '<div id="vote_counter" class="vote_counter-' . $post->ID . '">'. $votes.'</div><br>';

In voteme.js, replace:

jQuery("#vote_counter").html(response.vote_count);

..with:

jQuery(".vote_counter-" + post_id).html(response.vote_count);

You should also declare post_id and nonce as local variables; i.e.:

var post_id = $(this).attr("data-post_id"),
  nonce = $(this).attr("data-nonce");

Hope that helps.