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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:36:26+00:00 2026-06-11T16:36:26+00:00

I have a problem I can’t figure out. I have an ajax success function

  • 0

I have a problem I can’t figure out. I have an ajax success function that loops through a multidimensional array like so:

function onSuccessClientCustomerData(data) {
    // Count length of object
    var count = 0;
    for (i in data) {
        if (data.hasOwnProperty(i)) {
            count++;
        }
    }

    // Fetch data
    var arr = new Array(data.variable0, data.variable1, data.variable2, data.variable3, data.variable4);
    for(var i = 0; i< count; i++) {
        var variable = $.parseJSON(arr[i]);

    }
}

I each arrays have three keys and I want to populate the td:eq(1) to td:eq(2) on each row:

<table id="test">
<tr>
    <td><input type="text"></td>
<td class="outputName">-</td>
    <td class="outputRating">-</td>
<td class="outputTurnover">-</td>
</tr>
<tr>
    <td><input type="text"></td>
<td class="outputName">-</td>
    <td class="outputRating">-</td>
<td class="outputTurnover">-</td>
</tr>
</table>

How do I do that. I’ve tried som each functions but couldn’t get it to work!

Would be grateful for any help or references to read!

Thanks!

EDIT / HERE IS MY SOLUTION

function onSuccessClientCustomerData(data) {
    // Count length of object
    var count = 0;
    for (i in data) {
        if (data.hasOwnProperty(i)) {
            count++;
        }
    }

    // Fetch data
    var arr = new Array(data.variable0, data.variable1, data.variable2, data.variable3, data.variable4);
    for (var i = 0; i < count; i++) {
        var arr_j = $.parseJSON(arr[i]);
        $("#row" + i + " .key0").html(arr_j.name);
        $("#row" + i + " .key1").html(arr_j.rating);
        $("#row" + i + " .key2").html(arr_j.percentOfTotalIncome);
    }
}
  • 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-06-11T16:36:27+00:00Added an answer on June 11, 2026 at 4:36 pm

    Do you need help in the part where you have to insert the values? If so:

    jQuery Code

    function onSuccessClientCustomerData(data) {
        // Count length of object
        var count = 0;
        for (i in data) {
            if (data.hasOwnProperty(i)) {
                count++;
            }
        }
    
        // Fetch data
        var arr_i = new Array(data.variable0, data.variable1, data.variable2, data.variable3, data.variable4);
        for (var i = 0; i < count; i++) {
            var arr_j = arr_i[i];
            for (var j = 0; j < arr_j. length; j++) {
                $("#row" + i + " .key" + j).html(arr_j[j]);
            }
        }
    }
    

    HTML Code

    <table id="test">
      <tr id="row0">
        <td><input type="text"></td>
        <td class="key0" class="outputName">...</td>
        <td class="key1" class="outputRating">...</td>
        <td class="key2" class="outputTurnover">...</td>
      </tr>
      <tr id="row1">
        <td><input type="text"></td>
        <td class="key0" class="outputName">...</td>
        <td class="key1" class="outputRating">...</td>
        <td class="key2" class="outputTurnover">...</td>
      </tr>
    </table>
    

    Test Code

    I tested the code with Chrome and it worked fine. Here are the steps to reproduce it:-

    • Open the Elements pane using F12 and do the following:

      1. Add the HTML part to a webpage;
      2. Optionally add a border and some margins to make it clearer;

    • Open the Web Console using Ctrl + Shift + J and do the following:

      1. Give arr_i (we’ll be using that instead of data) a placeholder value:

        var arr_i = new Array([00, 01, 02], [10, 12, 13]);
        
      2. Run the code to set count:

        // Count length of object
                var count = 0;
                for (i in data) {
                    if (data.hasOwnProperty(i)) {
                        count++;
                    }
               }
        
      3. Use my function to add the values (be sure to run the code on a page that uses jQuery! Or else, use this bookmark):

        for (var i = 0; i < count; i++) {
            var arr_j = arr_i[i];
            for (var j = 0; j < arr_j. length; j++) {
                $("#row" + i + " .key" + j).html(arr_j[j]);
            }
        }
        

    And voilà! This should probably fetch me about 20 to 30 votes by today tomorrow this week next year (hopefully) …

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

Sidebar

Related Questions

Hy, I have a problem and I can't figure it out... declare @start_date datetime,
I have this problem I can't figure out, I query the DB this way:
I have problem I can't figure out but I do have a hint. Before
I have this problem that I can ref a button for control it. I
i have a problem that i can't solve ! (sqlite3, but i think it
I have a problem that I can't resolve. Let's say I have this map
I have a problem that can be simplified as follows: I have a particular
I have a problem that can essentially be viewed as a graph. I'm considering
I have a problem i can't find the wrong in this function it sometimes
I have a problem that can basically be summirized as: Byte[] barr = new

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.