Display Google Sheets JSON with JQUERY

Image from page 416 of "Minor and operative surgery, including bandaging" (1905)

I’ve been doing my Google JSON display using Angular but I wanted to see what I could do with jQuery.

This is based on the post here by Amit (to whom I am grateful for all the great stuff he puts out) with minor updates due to changes in how Google does things. Do make sure you’ve published your sheet at HTML and note that the 1 in the URL structure is the first page if you have multiple sheets.

<div class="results"></div> 
 
<script>
                     
// ID of the Google Spreadsheet
var spreadsheetID = "1xkfPWIYFdZpE9v9JMlmWSObxIHIjOKQdjB7qb4Nrdps";
                     
// Make sure it is public or set to Anyone with link can view 
var url = "https://spreadsheets.google.com/feeds/list/" + spreadsheetID + "/1/public/values?alt=json"; //this is the part that's changed
                     
$.getJSON(url, function(data) {
                     
    var entry = data.feed.entry;
                     
    $(entry).each(function(){
    //make sure this matches your column labels when you change the source sheet
    $('.results').prepend('<h2>'+this.gsx$title.$t+'</h2><p>'+this.gsx$url.$t+'</p>');
      });
                     
    });
                     
</script>

Comments on this post

No comments.

Leave a Reply

Trackbacks and Pingbacks on this post

No trackbacks.

TrackBack URL