我伙计,
我正在研究Phonegap应用程序和Sencha框架.
我尝试达到protected server但是Android的身份验证失败(但不是iOS).我使用下面的代码:
Ext.Ajax.request({
url:"http://user:[email protected]/query.json",
method: 'GET',
// I tried to send the header directly but it didn't work too
headers: {
"Authorization": "Basic s2dh3qs76jd2hqjsdh=="
},
success: function (result, request) {
alert(result);
},
failure: function ( result, request) {
for(var key in result)
alert(result[key]);
}
});
错误消息告诉我需要HTTP摘要…
想知道:
>互联网联系很好
>相同的代码适用于本地文件和其他外部API
>我不知道如何在LogCat中探索Javascript对象,请原谅我恶心的警报(结果[key])
谢谢你们,你们都摇滚!
解决方法:
我同意@Mariano.为什么你不能在浏览器中尝试它,然后部署为带有phonegap的应用程序.可以通过此命令从终端启动Google Chrome来解决跨域问题
google-chrome –args –disable-web-security
有关更多信息,请查看此链接
http://www.senchatouchbits.com/7/cross-domain-ajax-requests.html