getJson解析器没有'不起作用
getJson parser doesn't work
嗨,我正在尝试解析url的json响应,但我做不到。
$(document).ready(function() {
$.getJSON('https://www.googleapis.com/oauth2/v1/userinfo?&access_token=xxxxxxxxxxxxx&token_type=Bearer&expires_in=3600', function(data) {
alert (c.email);
});
});
在这个页面中有我的代码http://pastie.org/3379735
我希望你能帮助我。
什么是c.email,认为你想要data.email
$(document).ready(function() {
$.getJSON('https://www.googleapis.com/oauth2/v1/userinfo?&access_token=xxxxxxxxxxxxx&token_type=Bearer&expires_in=3600&callback=?', function(data) {
alert (data.email);
});
});
更新
正如OP在阅读文档后所说的那样,您需要为jsonp提供回调作为路径的一部分,而不是形式的params
https://oauth2-login-demo.appspot.com/oauthcallback?code={authorizationCode}
文档可以在这里找到
由于同源策略限制,您无法发送跨域AJAX请求。没有JSONP对此的支持,所以你不能直接从你的代码中访问他的url。
您可以查看以下基于gwt-oauth2.js脚本的演示,该脚本使用此代码向Google进行身份验证。
相关文章:
- electronic BrowserWindow的最小高度和宽度在hide()show()方法之后不起作用
- 监视函数从服务返回不起作用,但作用域函数起作用
- 幻灯片滚动javascript不起作用
- $.getJSON 在 Chrome 和 Safari 中不起作用
- 那么getJSon就不起作用了
- Javascript getJSON 不起作用(可能是跨域)
- getJSON 方法不起作用
- $.getJSON 在 IE10 中不起作用
- 为什么返回在getJSON中不起作用,为什么我不能从getJSON写入变量
- getJSON 在服务器上不起作用,但在本地工作
- $.getJSON没有'不起作用,但在脚本中包含JSON对象起作用
- 在pagebeforeshow中使用$.getJSON获取json数据在jquery mobile中不起作用
- 为什么我的$getjson电话不起作用
- getJson解析器没有'不起作用
- getJSON只响应明文,否则不起作用
- OpenWeatherMap.Org API - $.getJSON不起作用,我也没有接收到任何数据
- Getjson () jquery下拉菜单不起作用
- JSON_ENCONDE→getJSON不起作用
- PhoneGap中的$.getJSON不起作用
- $.getJSON不起作用