0

This is the website: enter link description here

Right now this is the function:

$("a.wtf").click(function(){
//get the id
the_id = $(this).attr('id');

// show the spinner
$(this).parent().html("<img src='images/thanks.fw.png'/>");

//the main ajax request
    $.ajax({
        type: "POST",
        data: "action=wtf&id="+$(this).attr("id"),
        url: "votes.php",
        success: function(msg)
        {
            $("span#votes_count"+the_id).fadeOut();
            $("span#votes_count"+the_id).html(msg);
            $("span#votes_count"+the_id).fadeIn();
            $("span#vote_buttons"+the_id).remove();
        }
    });
});

And this is the rest:

<a href='javascript:;' class='wtf' id='".$list['id']."'>

Rephrased: Right now, it displays an image after a user VOTES "WTF". How would I replace the Vote link with new text displaying the new value of the WTF vote (probably a result of the query)

3
  • Will you bother to rephrase your question Commented Nov 14, 2013 at 5:27
  • 1
    sure, done. Sorry man. I'm a moron. Commented Nov 14, 2013 at 5:34
  • your question is not clear. Commented Nov 14, 2013 at 5:56

1 Answer 1

1

Once you send the votes.php, hope you are update or insert the new vote, if is happenings like what i mention in this means , you also fetch the newly inserted or updated values from db then return to the callback function

Example :


    $total_votes=100;
    $reuslut=$total."-".'Thanks for vote';
    echo $result;
    exit;

 in call back function :
 ---------------------

    success: function(msg)
    {
       var value=msg.split("-");
        $("span#votes_count"+the_id).fadeOut();
        $("span#votes_count"+the_id).html(value[1]);
        $("span#votes_count"+the_id).fadeIn();
        $("span#vote_buttons"+the_id).remove();
        $(selector).html(value[1]);
    }

Hope it will help you for your question

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.