boruchsiper
boruchsiper

Reputation: 2028

Trying to .load() a public google spreadsheet

I'm trying to load a public google spreadsheet with Jq using the .load() function.

What am I doing wrong? http://jsbin.com/egetek/edit#javascript,html

$("#success").load("https://docs.google.com/spreadsheet/pub?key=0At4KrD3MMS40dFR0cm1ubGJGNnpnSWJZSVpDckpsWmc&single=true&gid=0&output=html", function(response, status, xhr) {
  if (status == "error") {
    var msg = "Sorry but there was an error: ";
    $("#error").html(msg + xhr.status + " " + xhr.statusText);
  }
});

The html:

<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
  article, aside, figure, footer, header, hgroup, 
  menu, nav, section { display: block; }
</style>
</head>
<body>
  <p id="success"></p>
  <div id="error"></div>
</body>
</html>

Upvotes: 0

Views: 218

Answers (1)

Michael Pryor
Michael Pryor

Reputation: 25346

I would guess it is because of the same origin policy.

See the Additional Notes:

Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, or protocol.

Upvotes: 1

Related Questions