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

  • Home
  • SEARCH
  • 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 3235968
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:34:03+00:00 2026-05-17T17:34:03+00:00

function manageVoting() { var parameter; var myVoting; var divVoting; var divVotes; var value =

  • 0
function manageVoting() {
    var parameter;
    var myVoting;
    var divVoting;
    var divVotes;
    var value = -1;
    var parameterData;
    $('div.votemaincontainer').each(function() {
        parameter = $(this).find('#[id$= hfUrl]').val();
        myVoting = parseInt($(this).find('#[id$=hfMyVote]').val());
        divVoting = $(this).find('[id$=divVoting]');
        divVotes = $(this).find('[id$=divVotes]');


        $('img.voteupImage').live('click', function() {
            if (myVoting == 1) {
                alert(" you have already voted");
            }
            else {
                value = 1;
            }
        });
        $('img.votedownImage').live('click', function() {
            if (myVoting == 0) {
                alert(" you have already voted");
            }
            else {
                value = 0;
            }
        });


        if (value == 0 || value == 1) 
        {
            parameterData = parameter + value + "'}";

            $.ajax({
                type: 'POST',
                url: 'UserControls/Vote/VoteAction.aspx/Voting',
                data: parameterData,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(data) {
                    var result = eval(data.d);

                    if (result) {
                        if (result.length > 1) {
                            alert("i am inside result here result length >1");
                            if (result[1] == 1 && result[2] == 1) 
                            {
                                $('img.voteupImage').attr('src', 'UserControls/Vote/Images/aftervote_arrow_up.png');
                                $('img.votedownImage').attr('src', 'UserControls/Vote/Images/arrow_down.png');
                                $('div.divVotes').html(result[0]);
                            }
                            else 
                            {
                                alert('U can not vote more than 1');
                            }
                            $('#[id$=hfMyVote]').html(result[1]);
                            if (result[1] == 0 && result[2] == 1) 
                            {
                                $('img.voteupImage').attr('src', 'UserControls/Vote/Images/Arrow_Up.png');
                                $('img.votedownImage').attr('src', 'UserControls/Vote/Images/aftervote_down.png');
                                $('div.divVotes').html(result[0]);  
                            }
                            else 
                            {
                                alert('U can not vote down more than 1');
                            }
                        }
                        else {
                            $('div.divVotes').html(result[0] - 1);
                            alertDialog("Rating any knowledge item is only available for Registered User.<br>Do you want to <a class='signUpPopUp' href='signup.aspx'> signup</a> Now?");
                        }

                    }
                },
                error: function() {
                    alert("i am inside error");

                }
            });
        }
    });
}



$(function() {
    manageVoting();
});

i have written above code but when i clicl on image then $.ajax does not executr what’s problem in code.

  • 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-17T17:34:04+00:00Added an answer on May 17, 2026 at 5:34 pm

    In the click live handlers, you’re only setting the value of the value parameter. You’re not executing the rest of the code after that. Try something like this (untested):

    function manageVoting() {
        var parameter;
        var myVoting;
        var divVoting;
        var divVotes;
        var value = -1;
        var parameterData;
        $('div.votemaincontainer').each(function() {
            parameter = $(this).find('#[id$= hfUrl]').val();
            myVoting = parseInt($(this).find('#[id$=hfMyVote]').val());
            divVoting = $(this).find('[id$=divVoting]');
            divVotes = $(this).find('[id$=divVotes]');
    
            function processVote(value) {
                if (value == 0 || value == 1) {
                    parameterData = parameter + value + "'}";
    
                    $.ajax({
                        type: 'POST',
                        url: 'UserControls/Vote/VoteAction.aspx/Voting',
                        data: parameterData,
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function(data) {
                            var result = eval(data.d);
    
                            if (result) {
                                if (result.length > 1) {
                                    alert("i am inside result here result length >1");
                                    if (result[1] == 1 && result[2] == 1) 
                                    {
                                        $('img.voteupImage').attr('src', 'UserControls/Vote/Images/aftervote_arrow_up.png');
                                        $('img.votedownImage').attr('src', 'UserControls/Vote/Images/arrow_down.png');
                                        $('div.divVotes').html(result[0]);
                                    }
                                    else 
                                    {
                                        alert('U can not vote more than 1');
                                    }
                                    $('#[id$=hfMyVote]').html(result[1]);
                                    if (result[1] == 0 && result[2] == 1) 
                                    {
                                        $('img.voteupImage').attr('src', 'UserControls/Vote/Images/Arrow_Up.png');
                                        $('img.votedownImage').attr('src', 'UserControls/Vote/Images/aftervote_down.png');
                                        $('div.divVotes').html(result[0]);  
                                    }
                                    else 
                                    {
                                        alert('U can not vote down more than 1');
                                    }
                                }
                                else {
                                    $('div.divVotes').html(result[0] - 1);
                                    alertDialog("Rating any knowledge item is only available for Registered User.<br>Do you want to <a class='signUpPopUp' href='signup.aspx'> signup</a> Now?");
                                }
    
                            }
                        },
                        error: function() {
                            alert("i am inside error");
    
                        }
                    });
                }
            }
    
            $('img.voteupImage').live('click', function() {
                if (myVoting == 1) {
                    alert(" you have already voted");
                }
                else {
                    value = 1;
                    processVote(value);
                }
            });
            $('img.votedownImage').live('click', function() {
                if (myVoting == 0) {
                    alert(" you have already voted");
                }
                else {
                    value = 0;
                    processVote(value);
                }
            });
        });
    }
    
    $(function() {
        manageVoting();
    });
    

    Also, when you’re using the JSON data type with $.ajax, you shouldn’t need to eval the data that comes back. jQuery already evaluates the JSON for you, and returns a native JavaScript object.

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

Sidebar

Related Questions

function selected() { var selObj = window.getSelection(); } This function returns selected text from
function ExChgClsName(Obj,NameA,NameB){ var Obj=document.getElementById(Obj)?document.getElementById(Obj):Obj; Obj.className=Obj.className==NameA?NameB:NameA; } <a href=javascript:showMenu(2);> i am a newbie of the
function heaviside(&$value, $key, &$array) { if($key > 0) $value = $array[$key-1].$array[$key]; } function test_heaviside()
function validateRequiredFields(formid) { var inputs = document.getElementsByClassName('required'); for(i=0;i<inputs.length;i++) { var FieldID = inputs[i].id; if(
function getWriters(cat, lev, id) { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome,
function contentDisp() { $.ajax({ url : a2.php, success : function (data) { $(#contentArea).html(data); }
function drawLabel(labelsIndex) { // Check not deleted Label data:(DBID, text, styling, x, y, isDeleted)
function someFunc() { return 'Hello, world'; } function call(funcName) { eval(funcName + '()'); }
function a($function, $array) { global $test $test->$function(implode(',' $array)); } For example, I want to
function oneWayEncrypt($string) { $salt = md5($string.yHuJ@8&6%4#%([@d-]); $salt2 = md5($string.@!#&+-)jU@[yT$@%); $string = hash('sha512',$salt$string$salt2); return $string;

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.