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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:08:05+00:00 2026-06-01T03:08:05+00:00

i am outputting json data from a php file (example of my output) {news:[{title:title

  • 0

i am outputting json data from a php file (example of my output)

{"news":[{"title":"title news example1","content":"blabla bla 1","img":"url"},
{"title":"title news example2","content":"blabla bla 2","img":"url2"},
{"title":"title news example3","content":"blabla bla 3","img":"url3"},
{"title":"title news example4","content":"blabla bla 4","img":"url4"}]}

how can i show all these data to div #news using jquery getjson or get and using each?

  • 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-01T03:08:07+00:00Added an answer on June 1, 2026 at 3:08 am

    This will use jQuery’s append() method to add an h2 and p tag for each article to the #news div. Obviously, you can customize the $.each callback as you need.

    Update the reason for your undefined errors was because the callback for the each() method was missing the index of the array as the first parameter. I updated my example appropriately.

    <script type="text/javascript">
      jQuery(function($){
        $.getJSON('uri/to/file.php', function(data) {
          $.each(data['news'], function(i, article){
            $('#news').append('<h2>' + article['title'] + '</h2><p>' + article['content'] + '</p>');
          });
        });
      });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi does anyone know how to stop json data from outputting in the browser
The autocomplete is outputting data in this format: <ul class=ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all>
I am trying to use JSON and HTTP client to retrieve data from a
I am facing problems in sending json response to php that I get from
I am having some trouble here, my json data is outputting as follows: {date:[{day_w:Tuesday,day_n:28,month:Dec}],subscriptions:[{subscribe:example1},{subscribe:example2},{subscribe:example3}]}
I just wanted some input about my use of JSON. <?php header('Content-Type: text/plain'); //results
I'm calling this example request from within some PHP code on a web page:
I was wondering if anyone had any pointers for parsing json data consumed from
I am outputting content from my models to my templates, however some model fields
When outputting images from Photoshop that are over 31 characters I get a compatibility

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.