我对 android 还很陌生,我遇到了一个问题,即带有 ajax 调用的页面没有加载到使用 Phonegap 开发的本机应用程序中。
跨域AJAX POST
请求在 Web 浏览器(包括手机浏览器)上运行良好,但不适用于使用 Phonegap 构建的本机应用程序。
我创建了一个应用程序durandal
,从中获取数据Facebook
并在页面中显示。它在浏览器中运行良好,但使用 ajax 调用的页面未加载到使用Phonegap
. 注意:其他静态页面工作正常。
我的 Ajax 脚本:
define(function(require){
return {
getCustomers:function(){
//do some ajax and return a promise
return $.ajax({
url: 'http://graph.facebook.com/facebook?callback=?',
dataType: 'json',
}).promise();
}
};
});
域白名单 - config.xml
<access origin="*"/>
<!-- <content src="http://mysite.com/myapp.html" /> for external pages -->
<content src="index.html" />
用户权限
<uses-permission android:name="android.permission.INTERNET" />
我有一个错误。不知道跟这个有关系吗?
TypeError: Result of expression 'parentElement' [null] is not an object. at file:///android_asset/www/js/index.js:41