来自Google Fusion表的Get请求有问题 [英] Trouble with Get request from Google Fusion tables
问题描述
我一直无法使用HTTP请求查询Google Fusion Tables。如果我在浏览器中粘贴下面查询中的URL,则会以逗号分隔列表返回。但是,当我使用.get函数执行此操作时,数据参数中没有任何内容返回。
I've been having trouble querying the Google Fusion Tables using an HTTP request. If I paste the URL from the query below in the browser, it comes back with a commas separated list. However, when I do this with the .get function as below, nothing comes back in the data parameter.
我对此很新,所以任何帮助都会受到赞赏。
I'm fairly new at this, so any help would be appreciated.
function query(){
var jqxhr=$.get(
"https://www.google.com/fusiontables/api/query?sql=SELECT+Address+FROM+914142+WHERE+IsCustomer+%3D+1",
function success(data, textStatus){
alert(data);})}
推荐答案
我一直在努力回来,就在今天下午发布示例代码和如何处理Fusion Tables查询的工作示例。
I was struggling with this a while back, and just this afternoon posted sample code and a working example of how to handle Fusion Tables queries.
简而言之,Mark完全相同的原始政策( http://en.wikipedia.org/wiki/Same_origin_policy ),除了一个细节外,他的解决方案就在那里 - 你需要用$ .get指定jsonp数据类型。请继续阅读 jQuery .get页面。
In a nutshell, Mark is exactly right about the same origin policy (http://en.wikipedia.org/wiki/Same_origin_policy), and was just about there with his solution aside from one detail - you need to specify "jsonp" datatype with $.get. Read on at the jQuery .get page.
根据您的原始示例,这应该有效:
Based on your original example, this should work:
function query(){
var queryurl = "<your query url>";
querytail = "&jsonCallback=?";
var jqxhr=$.get(queryurl + querytail, queryHandler, "jsonp")
}
function queryHandler(data) {
// display the first row of retrieved data
alert(data.table.rows[0]);
}
这篇关于来自Google Fusion表的Get请求有问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!