【发布时间】:2014-02-03 09:51:00
【问题描述】:
努力寻找通过 jQuery - Ajax 从 Google 的隐藏 api 获取 Google Plus +1 of page 的解决方案:https://clients6.google.com/rpc
这个问题也在:Stackoverflow link
我的尝试:
$.ajax({
cache: false,
type: "POST",
url: "https://clients6.google.com/rpc",
data: [{
"method":"pos.plusones.get",
"id":"p",
"params":{
"nolog":true,
"id":"http://www.apple.com",
//"id":"http%3A%2F%2Fwww.apple.com",
"source":"widget",
"userId":"@viewer",
"groupId":"@self"
},
"jsonrpc":"2.0",
"key":"p",
"apiVersion":"v1"
}],
crossDomain: true,
jsonp: true,
timeout: 5000,
dataType: "jsonp",
contentType: "application/json; charset=utf-8",
success: function (data) {
console.log(data);
},
always: function(data){
console.log(data);
}
});
结果在 chrome 中:Uncaught SyntaxError: Unexpected token :
在 Firefox 中: 语法错误:缺少;声明之前
{"error":{"code":-32700,"message":"Parse Error","data":[{"domain":"g
任何想法如何解决这个问题?
【问题讨论】:
标签: jquery ajax cross-domain google-plus