1
我只是在玩Google Fusion Tables,我想知道如何從客戶端加載csv。到目前爲止,我已經嘗試了幾種選擇:如何從客戶端應用程序加載Fusion Tables csv?
從ActionScript 3.0:
var r:URLRequest = new URLRequest("https://www.google.com/fusiontables/exporttable?query=select%20*%20from%203685185%20");
r.method = URLRequestMethod.GET;
var l:URLLoader = new URLLoader(r);
l.addEventListener(Event.COMPLETE,loaded);
l.addEventListener(HTTPStatusEvent.HTTP_STATUS,onHTTPStatus);
function onHTTPStatus(event:HTTPStatusEvent):void{
trace(event.status);
}
function loaded(event:Event):void{
trace(this.loaderInfo.url,event.target.data);
}
與ActionScript 2.0:
var vars:LoadVars = new LoadVars();
vars.onLoad = function(loaded):Void{
if(loaded) trace(unescape(this));
else trace("error loading data");
}
vars.onHTTPStatus = function(status:Number):Void{
trace(status);
}
vars.load("http://www.google.com/fusiontables/exporttable?query=select%20*%20from%203685185%20&r="+new Date().getMilliseconds());
從JavaScript:
$.get('https://www.google.com/fusiontables/exporttable?query=select%20*%20from%203685185%20',
function(data) { alert(data); });
在ActionScript一切工作獨立播放器,但不在線,這味道像某種安全沙箱問題。 在JS我得到這個:
XMLHttpRequest cannot load https://www.google.com/fusiontables/exporttable?query=select%20*%20from%203685185%20. Origin http://lifesine.eu is not allowed by Access-Control-Allow-Origin.
我查詢的表是公衆和導出。我也在Chrome上使用簡單REST客戶端嘗試了這個調用,並得到了正確的迴應。關於我可能錯過的任何提示?
[試過(http://lifesine.eu/test/fusiontable.html),但它並沒有使用你的工作第一個答案。我沒有很多js的經驗,我做錯了嗎? – 2012-04-27 03:23:50
完美運作!謝謝! _(注意它也可以在刪除'&jsonCallback =?'的動作中使用)_ – 2012-04-27 11:57:18