2012-03-06 6 views
0

私は、.load()関数を使用してJqでパブリックGoogleスプレッドシートを読み込もうとしています。公共のgoogleスプレッドシートを.load()しようとしています

私は間違っていますか? 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); 
    } 
}); 

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> 

答えて

1

私はそれが理由same origin policyのですよね。

Additional Notes参照:

により、ブラウザにセキュリティ制限を、最も「アヤックス」の要求が 同一生成元ポリシーの対象となります。その要求は別のドメイン、サブドメイン、またはプロトコルからのデータを正常に取得できません( )。

+0

私は同意します。基本的にあなたが何をしているのか、エラー処理をしています:http://jsfiddle.net/ufomammut66/xB4B7/ コンソールでクロムを見ると、Access-Control-Allow-Originエラーが出ます – ShortRound1911

関連する問題