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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:10:57+00:00 2026-06-11T14:10:57+00:00

If I have the some data being returned from my ajax call. I need

  • 0

If I have the some data being returned from my ajax call. I need to loop through and create an Html string that creates a table like:

 ID    NAME                  Object Type
 ==============================================
 1     SWT-F1-S32-RTR-1      Network Switch
 2     SWT-44-SR1-RTR-1      Network Switch
 etc.

Here’s what my json data looks like:

[
   {
      "name": "SWT-F1-S32-RTR-1",
      "id": "1",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-44-SR1-RTR-1",
      "id": "2",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-44-SR1-SW-1",
      "id": "3",
      "dict_value": "Network chassis"
   },
   {
      "name": "SWT-F1-S32-SW-2",
      "id": "4",
      "dict_value": "Network chassis"
   },
   {
      "name": "SWT-44-165-SW-1",
      "id": "5",
      "dict_value": "Network chassis"
   },
   {
      "name": "SWT-44-263-SW-1",
      "id": "6",
      "dict_value": "Network chassis"
   },
   {
      "name": "SWT-11-228-SW-1",
      "id": "7",
      "dict_value": "Network chassis"
   },
   {
      "name": "SWT-F1-S32-SW-1",
      "id": "8",
      "dict_value": "Network chassis"
   },
   {
      "name": "SWT-F2-204-SW-1",
      "id": "9",
      "dict_value": "Network chassis"
   },
   {
      "name": "SWT-R1-CC104-SW-1",
      "id": "10",
      "dict_value": "Network chassis"
   },
   {
      "name": "SWT-5-103-SW-1",
      "id": "11",
      "dict_value": "Network chassis"
   },
   {
      "name": "SWT-F1-1PF-SW-1",
      "id": "12",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-F1-1PE-SW-1",
      "id": "13",
      "dict_value": "Network chassis"
   },
   {
      "name": "SWT-11-123-SW-1",
      "id": "15",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-32-M402-SW-1",
      "id": "17",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-66-102-SW-1",
      "id": "18",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-R1-CC011-SW-1",
      "id": "19",
      "dict_value": "Network chassis"
   },
   {
      "name": "SWT-R1-CC239-SW-1",
      "id": "20",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-R1-CCPH-SW-1",
      "id": "21",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-32-K218-SW-1",
      "id": "23",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-SB1-204-SW-1",
      "id": "24",
      "dict_value": "Network chassis"
   },
   {
      "name": "SWT-SB3-107-SW-1",
      "id": "25",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-SB4-110-SW-1",
      "id": "26",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-5-119-SW-1",
      "id": "27",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-F2-113-SW-1",
      "id": "39",
      "dict_value": "Network chassis"
   },
   {
      "name": "Core Switch HSRP",
      "id": "91",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-MLO-106-SW-1",
      "id": "275",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-STP-001-SW-1",
      "id": "277",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-F1-169-SW-1",
      "id": "281",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-R1-F108-SW-1",
      "id": "283",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-GH-001-SW-1",
      "id": "285",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-11-228-SW-2",
      "id": "301",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-44-010-SW-1",
      "id": "303",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-44-141-SW-1",
      "id": "305",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-F1-169-SW-2",
      "id": "309",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-F2-114-SW-1",
      "id": "311",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-66-114-SW-1",
      "id": "313",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-R1-1109-SW-1",
      "id": "315",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-32-L009-SW-1",
      "id": "317",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-SB1-204-SW-2",
      "id": "319",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-5-103-SW-2",
      "id": "321",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-5-114-SW-1",
      "id": "323",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-F1-1PL-SW-1",
      "id": "325",
      "dict_value": "Network chassis"
   },
   {
      "name": "CAES-0xx-CAGE",
      "id": "365",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-R1-H109-SW-1",
      "id": "379",
      "dict_value": "Network chassis"
   },
   {
      "name": "SWT-FM-001-SW-1",
      "id": "385",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-LSQ-BSMT-SW-1",
      "id": "415",
      "dict_value": "Network switch"
   },
   {
      "name": "SWT-44-152-SW-1",
      "id": "417",
      "dict_value": "Network chassis"
   }
]

EDIT 1
Here’s the code I have so far:

    $.ajax({
            url:"<?php echo site_url('switches/getallswitches/');?>",
            type:'POST',
            dataType:'json',
            success: function(returnDataFromController) {
                    var htmlstring;
                    htmlstring="<select name='L2Locations' id='L2Locations'>";
                    htmlstring = htmlstring + "<option value='all'>All</option>";

                    //console.log(returnDataFromController);
                     var JSONdata=returnDataFromController;
                     console.log(JSONdata);
                     if (JSONdata.length != 0) 
                     {
                            $.each(JSONdata, function(i, objswitch) {
                            var row = $('<tr class="alt2 section_1">').appendTo($('#table'));
                            row.append($('<td>').append($('<strong>').text(objswitch.name)));
                            $.each(objswitch.id, function(j, comparisonValue) {
                                row.append($('<td>').text(comparisonValue));
                            });
                        });

                     }

                }//success


        });//end ajax

It’s based on the example in the other post. But i’m not sure how to convert “row” into an html string so i can ultimately do something like (#nameofdiv).html(htmlstring).

Sorry to all the guys who have read this post so far. It’s been a crazy day and not that you have to check my other posts before you make nasty remarks, but for what it’s worth, i have been working on some interesting ajaax problems with others on stackoverflow today. And I guess I was just too quick to hit enter. I got nailed immediately! wow. Anyways. Thanks for being patient. Hopefully, this post is a little clearer.

  • 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-11T14:10:59+00:00Added an answer on June 11, 2026 at 2:10 pm

    The problem was that the table name referenced in the loop was incorrect.

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

Sidebar

Related Questions

I have the following JSON data being returned, but for some reason, Javascript or
I have a question regarding the some data which is being transfered from one
I have some data and need to create a json file with this structure
I have some code that requests some JSON from an API. When data is
I am trying to create a clustered image from data being returned from the
A] Problem summary: I have JSON data being returned from python to javascript. I
I have a data result being returned from my database with multiple rows. The
I have some Json being returned from facebook which I'm then parsing in to
I have some data loaded as a np.ndarray and need to convert it to
I have some data from log files and would like to group entries by

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.