Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6192205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:54:15+00:00 2026-05-24T02:54:15+00:00

I have the following AJAX function to update votes clicked. $(function() { $(.vote).click(function() {

  • 0

I have the following AJAX function to update votes clicked.

$(function() {
            $(".vote").click(function()
            {
            var id = $(this).attr("id");
            var name = $(this).attr("name");
            var dataString = 'id='+ id ;
            var parent = $(this);

            if (name=='up')
            {
            $(this).fadeIn(200).html('<img src="/content/voting/yes-enb.JPG" />');
            $.ajax({
            type: "POST",
            url: "up_vote.php",
            data: dataString,
            cache: false,

            success: function(html)
            {
            parent.html(html);
            }
            });
            }

});

and the div/span html code is as below

<span class="vote"  id="53" name="up" style="text-decoration:none; color:none; margin:5px; ">
<img src="/content/voting/yes-enb.png" width=12 height=12 alt=""> 
<span style="text-decoration:none; color:none">'.$up.' </span></span>

So the above AJAX code increments the counter every time the user clicks the vote button. However in this case the vote img as well as the count of vote gets refreshed. All I want is that the ‘.$up.’ part gets refreshed. that is only the vote section.

Any idea how this could be done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:54:15+00:00Added an answer on May 24, 2026 at 2:54 am

    You should use the data from the request to only update the span inside of the span with the class ‘vote’.

    So change

    parent.html(html);
    

    to

    parent.find('span').html(html);
    

    Make sure your php file only returns the vote value to avoid duplicating the arrow 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that works on Firefox and Chrome $("#adicionarItem").click(function(){ $.ajax({ type:
The problem is the following. We have lots of ajax call via $.ajax function.
I have the following function that is pulling data from a database. The ajax
I have the following piece of code: // setup the AJAX request var pageRequest
I've started the following skeleton for an ajax/post/update function I'm wanting to write in
I have put together the following mootools script window.addEvent('domready', function() { var shouts =
I have the following ajax call to update a particular field of a model
Let's say I have the following jQuery AJAX call: $.ajax({ type: POST, url: MyUrl,
I have the following javascript: $.ajax({ type: "POST", dataType: "json", url: "/Home/Submit", data: {
I have the following HTML structure being returned from an AJAX request... <th scope=col

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.