下面是我从融合表中选择行的代码。我有错误401在此响应,即需要授权。怎么做呢?我找不到足够的添加它,或者可能是我没有得到它:/任何帮助都会很感激。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Fusion Tables Layer Example: Basic JSONP Request</title>
<style type="text/css">
#map-canvas {
height: 500px;
width: 600px;
}
.store-name {
font-weight: bold;
margin: 10px 0px 0px 0px;
padding: 0px;
}
.address, .delivers {
margin: 0px;
padding: 0px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="https://apis.google.com/js/plusone.js"></script>
<script type="text/javascript">
function initialize() {
var query = "SELECT * FROM " +
'15UY2pgiz8sRkq37p2TaJd64U7M_2HDVqHT3Quw';
var encodedQuery = encodeURIComponent(query);
// Construct the URL
var url = 'https://www.googleapis.com/fusiontables/v2/query?sql=' + encodedQuery + '&key=AIzaSyC41SwODXKVFnY4UrgeRwYZk1Ah_7eLgkw';
console.log(url);
// Send the JSONP request using jQuery
$.ajax({
url: url,
dataType: 'jsonp',
type: 'GET',
Authorization : 'Basic MTBiaXR0ZmF0aW1hQHNlZWNzLmVkdS5wazp0QHl5YkA5Mg==',
success: function (data) {
alert('in success function ');
var rows = data['rows'];
var ftData = document.getElementById('ft-data');
console.log(data);
}
});
}
</script>
</head>
<body>
<button onclick="initialize();">Authorize</button>
<div id="ft-data"></div>
</body>
</html>
响应返回:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
你的表是私有的这就是为什么你会得到这个只是去到表,点击分享按钮然后改变"谁有访问任何人的链接可以查看"