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 6234729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:32:22+00:00 2026-05-24T10:32:22+00:00

I am trying to run a simple post call which checks for updates and,

  • 0

I am trying to run a simple post call which checks for updates and, if there are any, updates the specific element.
My problem is that inside the fadeOut function (which is implemented to allow for a smooth fadeOut and fadeIn), my variable i (used as a count) is incremented by one without doing it myself.
I tried renaming the variable to count instead, but the same behavior happened. I can’t see where this is happening, or why it is, and even console.log with the variable outside the fadeOut function doesn’t reveal anything.

Anyone have any ideas as to what is going on ?

My code is below.

Javascript:

$.post(BaseUrl + $(this).val(), function (data) {
    var i = 0;
    $(element).parent().children(".MenuLink").each(function(index, e) {
        if ($(this).text() != data[i]['Value']) {
            $(this).fadeOut(function() {
                $(this).html('<a href="' + data[i]['Key'] + '"class="psuedolink personlink">' + data[i]['Value'] + "</a>");
                $(this).fadeIn();
            });
        }
        i++;
    });
});

HTML:

<div id="ActorMenu" class="Menu LastMenuItem">
    <div id="ActorLabel" class="Label">Actor</div>
    <div id="ActorDropdown" class="Dropdown">
        <input id="ActorSearch" type="text" />
        <hr />
        <a class="MenuLink FirstDropdownItem" href="/Network/reveal_network_7777/Behavior/Summary/Actor/actor_id_0">actor_0</a>
        <a class="MenuLink" href="/Network/reveal_network_7777/Behavior/Summary/Actor/actor_id_1">actor_1</a>
        <a class="MenuLink" href="/Network/reveal_network_7777/Behavior/Summary/Actor/actor_id_2">actor_2</a>
        <a class="MenuLink" href="/Network/reveal_network_7777/Behavior/Summary/Actor/actor_id_3">actor_3</a>
        <a class="MenuLink" href="/Network/reveal_network_7777/Behavior/Summary/Actor/actor_id_4">actor_4</a>
    </div>
</div>
  • 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-24T10:32:23+00:00Added an answer on May 24, 2026 at 10:32 am

    This is happening because when the each loop is executed the value of i has already incremented and when fadeOut callback is executed the value of i has already changed. Try this

    $.post(BaseUrl + $(this).val(), function (data) {
        var i = 0;
        $(element).parent().children(".MenuLink").each(function(index, e) {
            if ($(this).text() != data[i]['Value']) {
                $(this).data("i", i).fadeOut(function() {
                    var count = $(this).data("i");
                    $(this).html('<a href="' + data[count]['Key'] + '"class="psuedolink personlink">' + data[count]['Value'] + "</a>").fadeIn();
                });
            }
            i++;
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a simple chat bot for Adium, that will post lol
I'm trying to run a c++ 2d array (pretty simple file) and it works
I'm trying to run a LINQ to SQL query that returns a result in
I am trying to run xcopy that copies files excluding .obj, etc. What I
What I am trying to do is to run a simple Servlet from a
I'm trying to write a POST call to Google Translate with Jersey 1.5. This
Hi thank you in advance for any help, I'm trying to build a simple
I'm trying to do something simple to practice my Javascript (which I learned some
I am trying to run the VS 2008 SP1 installer , but it says
I'm trying to run a batch file, as another user, from my web app.

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.