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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:05:57+00:00 2026-06-14T03:05:57+00:00

So I have data in JSON format from the Guardian API’s open platform I

  • 0

So I have data in JSON format from the Guardian API’s open platform I would like to parse this in jquery and I currently stuck trying to display results onto my HTML div.

The format of the data is as follows: Guardian JSON results

My code that I am trying to work with is as follows

    function processFootballData(footballData){
    footyStuff = footballData;
    var thisContainer = document.getElementById( "results" );
    var listTmp = document.createElement( "ul" );
    var tmpList = "";
    for( var i=0; (i<footyStuff.results[0].length) && (i<100); i++ ) {
            if( tmpList.length <= 0 ) {
                tmpList = footyStuff.results[0][ i ];
            }
            else {
                tmpList = tmpList + "," + footyStuff.results[0][ i ];
        }
    }

    var footballURL = "http://content.guardianapis.com/search?q=football&format=json&api-key=ky5zy8mds5r25syu36t9kmzj";
    $.getJSON( footballURL,
            function( thisData ) {
            var data = thisData;

            for( var key in data ) {
                    var thisSublist = document.createElement( "ul" );
                    thisSublist.setAttribute('style', "border-bottom: 1px solid #000; width: 80%;");
                    var thisItem = document.createElement( "li" );
                    var footyResults = data[key].results[0];

                    if( data.hasOwnProperty( key ) ) {
                        var duyList = document.createElement("li");
                        duyList.setAttribute('style', "padding-bottom: 10px;margin-top:-15px;margin-left:53px;font-size:12px;");
                        duyFooty = document.createTextNode(footyResults);
                        duyList.appendChild(duyFooty);
                        thisItem.appendChild(duyList);
                    }

                    thisItem.appendChild( thisSublist );
                }
                listTmp.appendChild( thisItem );
        }
        thisContainer.appendChild( listTmp );
});

}
  • 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-14T03:05:58+00:00Added an answer on June 14, 2026 at 3:05 am

    You need to use a jsonp request, because the Guardian API is blocking cross-domain requests. Use the JQuery .ajax with dataType: jsonp:

    $.ajax({
        url: footballURL,
        dataType: 'jsonp',
        success: function( thisData ) {
            var data = thisData;
            // etc ...
        }
    });
    

    Your DOM-generation Javascript is a bit of a mess … but it’s easy to get lost writing that kind of code. I’d strongly recommend using some kind of micro-templating engine to handle the data-to-HTML conversion stuff.


    Here’s an example of how to do this using Mustache.js.

    // create HTML template with data tags
    var template = "<ul>{{#results}}<li><ul><li><a href='{{webUrl}}'>{{webTitle}}</a></li></ul></li>{{/results}}";
    
    // render output
    var output = Mustache.render(template, thisData.response);
    
    // add to the DOM
    $("#results").html(output);
    

    Here’s the same example using Underscore.js. Same idea, but different implementation that lets you write the template as markup:

    <script type='text/template' id='article-template'>
        <% _.each(results, function(article) { %>
        <ul>
            <li style="border-bottom: 1px solid #000; width: 80%;">
                <a href='<%= article.webUrl %>'><%= article.webTitle %></a>
            </li>
        </ul>
        <% }); %>
    </script>
    

    ​
    And the script to render:

    var template = _.template($("#article-template").html());
    var output = template(thisData.response);
    $("#results").html(output);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application which obtains data in JSON format from one of our
i have json data like this {GetStudentDetails: {TotalCount:5, RootResults:[ {city:West Chester,country:USA,state:PA ,student_id:100}, {city:Philly,country:USA,state:PA,student_id:101}, {city:Buffalo,country:USA,state:NY,student_id:102},
I have a JSON data like this: { hello: { first:firstvalue, second:secondvalue }, hello2:
Hi I have created an activity which pulls data from json format text and
I have an API in php, that sends data in JSON format. I made
In controller code, I have data in json format data = { 1: {assetId:1,status:true},
I have a text file that contains cached data in JSON format. I'm trying
I have a dynamic json data having the format var cols= { columns :
I have a outsource data from : http://example.com/data/news.json Here is the example result after
I have a php query the returns the following JSON format from a table.

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.