【发布时间】:2013-11-12 11:16:22
【问题描述】:
我是 android 的新手,我遇到了一个问题,即带有 ajax 调用的页面没有加载到使用 Phonegap 开发的本机应用程序中。
跨域AJAX POST-request 在网络浏览器(包括手机浏览器)上运行良好,但不适用于使用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
【问题讨论】:
标签: android jquery ajax cordova durandal