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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:58:01+00:00 2026-06-05T04:58:01+00:00

I try to display JSON data in html file with jQuery. But in html

  • 0

I try to display JSON data in html file with jQuery.

But in html I have nothing for output even null or unindefied

I try with external JSON data from Flickr and I see at least [Object]

Also I try to test both files – HTML and JSON on local server – again nothing

I add MIME Type on my server for application/json

I checked JSON- it’s valid

In Firebug I see JSON Response (see image below)

On same page I use and jQuery mobile and DW Fluid grid layout if it matters.

my JSON is generated with PHP json_encode:

({ "title": "Art and Culture",
"items": [
{"id":"kunst-im-tunnel","lat":"51.219917"},
{"id":"kunsthalle","lat":"51.227568"},
{"id":"kunstsammlung-nordrhein-westfalen","lat":"51.22841"}]
})

PHP code for JSON

<?php
header('Cache-Control: no-store, no-cache, must-revalidate, private, post-check=0, pre-check=0');
header('Pragma: no-cache'); 
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); 
header('Content-type: application/json; charset=utf-8');
$out = json_encode($post);
echo "({ \"title\": \"Art and Culture\",\"items\": " .$out." })";
?> 

my javascript code is:

$.getJSON("http://example.com/app.php?cat=category&jsoncallback=?",
{format: "json"},
function(data){
    $.each(data.items, function(i,item){

        $('<li>' +  item.id + '</li>').appendTo("#list");

    });

});

Screenshot from Firebug:
Firebug Net result

  • 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-05T04:58:04+00:00Added an answer on June 5, 2026 at 4:58 am
    ({ "title": "Art and Culture",
    "items": [
    {"id":"kunst-im-tunnel","lat":"51.219917"},
    {"id":"kunsthalle","lat":"51.227568"},
    {"id":"kunstsammlung-nordrhein-westfalen","lat":"51.22841"}]
    })
    

    IS NOT VALID JSON.

    But this one is Valid JSON

     { "title": "Art and Culture",
       "items": [
                  {"id":"kunst-im-tunnel","lat":"51.219917"},
                  {"id":"kunsthalle","lat":"51.227568"},
                  {"id":"kunstsammlung-nordrhein-westfalen","lat":"51.22841"}]
     }
    

    And it will work nicely. Here is the working sample http://jsfiddle.net/cqfQp/1/

    Use jsonlint to validate JSON.

    Another suggestion is, Try to avoid calling the append function in a loop. Create a variable and call the function only once. Something like this

         var strItems="";
         $.each(data.items, function(i,item){
             strItems+='<li>' +  item.id + '</li>';
         });
         $("#list").html(strItems); 
    

    EDIT : Make sure you call the getJSON on document ready function

     $(function(){
          $.getJSON("http://example.com/app.php?cat=category&jsoncallback=?",function(data){
            var strItems="";
            $.each(data.items, function(i,item){
                strItems+='<li>' +  item.id + '</li>';
            });
            $("#list").html(strItems);    
         });
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am generating the html using JSON file. Now I need to pass data
I have the following aspx/html page, it uses jquery to display a modal form.
I try to display some data in my Sencha touch application, but it doesn't
I'm try display data from column points , SELECT * from table ORDER by
I try to get one data column from a MS-Access table and display it
I have the following HTML file: <div class=tituloD> </div> <div class=subtituloD> </div> <div class=puntosD>
I am using ASP.net to display data on my calendar. I have my feed
I'm loading quite a bit of json data through a jquery/ajax/php get. When I
I have JSON data which contents Strings and Image URLs, and I already parse
i have this jquery code which poplautes a input selector, which should display like

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.