Patrik W Patrik W - 1 year ago 112
JSON Question

Get data from Google sheet using json

I have created a Google sheet where I´ve put a lot of logic and functions. Now I just want to import data from the sheet into my webiste (using MVC in my html project).

I read about it on this site:

It all seem easy and that it should work fine just using his code, but perhaps I am missing something. Below is my code, only added the $(document).ready part and my spreadsheet ID.

<div class="results"></div>


// ID of the Google Spreadsheet
var spreadsheetID = "1-JfSulb2FIh0C-hyy-ihYV0ieFi3ephC75oYB1mrKr8";

// Make sure it is public or set to Anyone with link can view
var url = "" + spreadsheetID + "/od6/public/values?alt=json";
$(document).ready(function () {
$.getJSON(url, function(data) {

var entry = data.feed.entry;

// Column names are name, age, etc.


So the problem is that I don´t get any data from the sheet into my html div. However I try it´s just empty. Is there something else I need to do to get it to work? I´ve named the cells in the first row to name and age but get nothing.

My Google sheet:

Is there something I need to do in the sheet other than making it public and copy the code into my project? I guess this is a noob question but I just can't get it to work. Any help would be greatly appreciated!

Answer Source

There was no error in the code.

I had for some reason deleted the jQuery part in my _Layout page

<script src="~/lib/jquery/dist/jquery.js"></script>

Stupid mistake which I didn't think about looking for. Anyways now it works just fine :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download