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

  • Home
  • SEARCH
  • 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 6677891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:10:40+00:00 2026-05-26T04:10:40+00:00

I have valid data in jquery, how to I loop every item I get

  • 0

I have valid data in jquery, how to I loop every item I get back and display it in html container div. Thanks

ie.

item 1
image 123
Item 2
Image 123

{"ERRORS":[],"DATA":[{"itemValidFrom":"October, 25 2011 00:00:00","itemActive":true,"itemTxt":"test","itemID":"30d2f2c1-58ca-4b3d-b3e0-d284ae5b25ab","itemValidTo":"October, 19 2011 00:00:00","itemName":"test","itemModified":"October, 05 2011 00:00:00","itemCreated":"October, 03 2011 00:00:00","image":{"imageCreated":"October, 05 2011 00:00:00","imageURL":"firefox-girl.jpg","imageID":"bc869a94-fee5-4fc8-bd21-e2de2f020310"}],"MESSAGES":[{"CURRENTPAGE":1.0,"TOTALPAGES":1.0}]}

<script type="text/javascript">
    jQuery(document).ready(function(){

    jQuery.ajax({
    type: 'get',
    url: 'api/default.php/id/0f4addd8',
    data: 'apiKeytest=182j&?perPage=2&currentPage=1',
    dataType: "json",
    context: document.body,
    success: function(r) {
    jQuery('#posts-container').replaceWith(r);
            console.log(r);
                        }

    });

    });

</script>


<!-- Widget HTML Starts Here -->
<div id="posts-container">
    <!-- Posts go inside this DIV -->
    <div id="posts"></div>
    <!-- Load More "Link" -->
    <div id="load-more">Load More</div>
</div>
<!-- Widget HTML Ends 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-26T04:10:41+00:00Added an answer on May 26, 2026 at 4:10 am

    You can loop through the json data with a for loop and build your custom output to append to the DOM:

    success: function(r) {
        var output = '';
        for (a in r.DATA) {
            for (b in r.DATA[a]) {
                if (typeof(r.DATA[a][b]) == 'object') {
                    for (c in r.DATA[a][b]) {
                        output += c + ' = ' + r.DATA[a][b][c] + '<br />';
                    }
                } else {
                    output += b + ' = ' + r.DATA[a][b] + '<br />';
                }
            }
        }
        jQuery('#posts-container').append(output);
    }
    

    a corresponds to each key in the object returned by your ajax call.

    I created a jsfiddle of the above code and noticed that there is an error in the json output you posted in your question; a closing bracket (}) was omitted from the end of the DATA array (which has only one key, 0).

    Here is the link to the jsfiddle: http://jsfiddle.net/EpjyH/1/

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

Sidebar

Related Questions

I have an object that needs a test if the object data is valid.
I have a form that uses JQuery Validate plugin to validate the data. For
I have defined an ajax dataFilter for my jQuery calls that return JSON data
I have a client-side script written in jQuery that is sending text/xml data to
My question may not make sense but I have valid reason. We use .net
I have a valid link that goes to a picture located on my web
My problem involves checking if I have a valid database connection before reading from
I have a text field and am looking to have if be valid for
I have some constants that represent the valid options in one of my model's
I have a template class that is only valid for couple of template parameters:

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.