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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:15:37+00:00 2026-05-25T10:15:37+00:00

i am working on a page wherein i have 2 nested loops, my problem

  • 0

i am working on a page wherein i have 2 nested loops, my problem is… Say for Example the current value for outer loop is 1 and shall execute 1times. and inner loop shall execute 2times. now when i alerts the value of outer loop in the inner loop, it throws me 2, on first attempt.. i dont understand how it gets 2, as my intial value is 1 and condition is <=1. and when i try to print the value of inner loop, it returns 1 on first and 0 second time… this is crazy behaviour… i am totally stuck here… below is my code.

for (i = 1; i <= _leftSectionCount; i++) //_leftSectionCount is 1{
                    $("#tdSection" + i + "Image").html("<img width='500' height='35' src='/newsletterimage/section" + i + ".gif'>");
                    var rows = $("#divLeft" + i + "tbody1 td:nth-child(1)"); // has 2 rows
                    if (rows.length > 0) {
                        $("#tdSection" + i + "Data").append("<table id='tblSection" + i + "Data'></table>");
                        $("#tblSection" + i + "Data").html("");
                    }
                    rows.each(function (index) {
                        $.ajax({
                            type: "POST",
                            url: "AjaxMethods.aspx/GetArticleDetails",
                            data: "{'articleId':'" + $(this).text() + "'}",
                            dataType: "json",
                            contentType: "application/json",
                            success: function (data) {
                                var results = data.d;
                                alert("$(#tblSection" + i + "Data')"); // this returns me 2.
                                 alert("$(#tblSection" + index + "Data')"); // this returns me 1 and 0.
                                $("#tblSection" + i + "Data").append("<tr><td>" + results[0].Title + "</td></tr>");
                            },
                            error: function (data) { alert(data.responseText); }
                        });
                    })

                    WriteToFile();
                }

Anyone please help me i am totally stuck here.

  • 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-25T10:15:37+00:00Added an answer on May 25, 2026 at 10:15 am

    Your responses are coming back async, so i will be whatever it is, when it returns, change to async=false to keep i and index in sync(no pun):

    rows.each(function (index) {
        $.ajax({
        type: "POST",
        url: "AjaxMethods.aspx/GetArticleDetails",
        data: "{'articleId':'" + $(this).text() + "'}",
        dataType: "json",
        async: false, //HERE
        contentType: "application/json",
        success: function (data) {
            var results = data.d;
            alert("$(#tblSection" + i + "Data')"); // this returns me 2.
             alert("$(#tblSection" + index + "Data')"); // this returns me 1 and 0.
            $("#tblSection" + i + "Data").append("<tr><td>" + results[0].Title + "</td></tr>");
        },
        error: function (data) { alert(data.responseText); }
        });
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a page has an ol with nested p's, div's, and li's.
I'm trying to get an html5 demo page working on Android 2.1, have tried
I've been working on a Windows SideBar Gadget wherein I have multiple flyout pages.
I am working on a query page where a user selects a value which
I'm working on a website wherein the home page for a user includes some
I have an existing form on my working php page. <form action=index.php method=POST> ...
I have a working jQuery page redirect. I want to fade into the page
I have web page working properly on Ie 7 and mozilla but when opened
$(document).ready(function() not working after page refresh in ie 6.Is there any problem to use?Whether
Ok im trying to get a MVC example page working and basically query where

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.