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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:51:54+00:00 2026-05-27T19:51:54+00:00

I am recieving JSON data in this format:- { sEcho:1, total:1710, aaData:[ [ Help,

  • 0

I am recieving JSON data in this format:-

{
"sEcho":1,
"total":"1710",
"aaData":[
    [
        "Help",
        "http:\/\/www.mysite.com\/wp-content\/uploads\/2011\/09\/dt_intfc4e732d1f1276d_4e76fab1e95bd.mp3?King_of_Spain_Entropy_02_Animals_Part_1.mp3",
        "1784",
        "3",
        0,
        null,
        "0000-00-00 00:00:00"
    ],
    [
        "A Day In The Life",
        "http:\/\/www.mysite.com\/wp-content\/uploads\/2011\/09\/dt_intfc4e732d1f1276d_4e76f5fc253a1.mp3?JenWood_Zeppelin.mp3",
        "3573",
        "3",
        0,
        null,
        "0000-00-00 00:00:00"
    ]
}

Using a typical jquery ajax request like so:-

 $.ajax({
    "dataType": 'json',
    "url": '/wp-content/hovercard.php',
    "data": 'order=' + $orderValue + '&orderColumn=' + $columnValue,
    "success": function(data, textStatus, jqXHR) {


        //loop JSON array and build html string here, then append it.

         }

  });

How do I loop through the nested objects within this JSON array in order to build a list of ‘TR’ nodes and then insert them into a table?

If I use the first data object in my JSON array example above, I would like the html string returned like this:-

 <tr class="odd">
      <td> + help + </td>
      <td><a href=" + http:\/\/www.mysite.com\/wp-content\/uploads\/2011\/09\/dt_intfc4e732d1f1276d_4e76fab1e95bd.mp3?King_of_Spain_Entropy_02_Animals_Part_1.mp3 + "> + help + </a></td>
      <td> + 1784 + </td>
      <td> + 3 + </td>
      <td> + 0 + </td>
      <td> + null + </td>
      <td> + 0000-00-00 00:00:00 + </td>
</tr>

To make matters more confusing the ‘tr’ class of “odd” as shown above, needs to be alternated with a class of “even” for each data index.

Then once the full html string of all the ‘tr’ nodes has been built and saved into a variable (lets use $newContent) I would like to append it to a table. i.e.

$('#my_table').append($newContent);

So far I have worked out how to iterate over the data and create the required ‘tr’ nodes as such:-

  var array = data.aaData;
    var textToInsert = [];
    var i = 0;

                $.each(array, function(count, item) { 
                textToInsert[i++]  = '<tr><td class="odd">';
                textToInsert[i++] = item;
                textToInsert[i++] = '</td></tr>';
                                    });

$('#favourites-hovercard-table-'  + $artistid ).append(textToInsert.join(''));

But I am struggling with iterating over the nested data and building the required ‘td’ nodes as well as alternating the odd/even classes.

  • 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-27T19:51:54+00:00Added an answer on May 27, 2026 at 7:51 pm

    I’d suggest to use proper DOM manipulation instead of creating strings:

    var $table = $('#favourites-hovercard-table-'  + $artistid );
    
    $.each(data.aaData, function(i, row) {
        var $tr = $('<tr />', {'class': (i % 2) ? 'odd' : 'even'});
        $.each(row, function(j, value) {
            $tr.append($('<td />', {text: value})); 
        });
        $table.append($tr)
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a web service that returns JSON data. test.com/incident.do?JSON&sysparm_action=getRecords Loading this URL
I am recieving an error: Notice: Undefined variable: content in C:\wamp\www\includes\imdbgrabber.php on line 17
I'm trying to set up jsTree to dynamically accept JSON data from django. This
My json data being retrieved is as of below, notice that the format is
In summary I retrieve a HTTP Web Response containing JSON formatted data with unicode
This code example is from the APE official website: http://www.ape-project.org/ var client = new
I'm using net/http to pull in some json data from the Yahoo Placemaker API.
is there any small working program for recieving from and sending data to client
I am in trouble with the bing's json api. Here is the json data
I am using JSON to parse data and connect to a PHP file. I

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.