【发布时间】:2013-12-05 09:32:20
【问题描述】:
我已经为此工作了很长时间,并且正在努力寻找问题的解决方案。
我正在使用 IOS 平台使用 cordova (phonegap) 3.1.0。我最初使用 xcode iphone 模拟器开发了一个应用程序,它运行良好。不幸的是,当我尝试在 ipad 上运行我的应用程序时,假设触发 json 生成的 jquery 不起作用。
我尝试包含以下代码,但仍然没有运气...
$.support.cors = true;
$.mobile.allowCrossDomainPages = true;
我目前正在使用 jquery mobile-1.3.2.js
这是我的 index.html 文件的标题
<script type="text/javascript" src="cordova.js"></script><script> document.addEventListener("deviceready", onDeviceReady, false); function hyperlink(){ window.location = "introduction.html"; } </script> <link rel="stylesheet" type="text/css" href="css/index.css" /> <link rel="stylesheet" href="css/themes/default/jquery.mobile-1.3.2.css"> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery.mobile-1.3.2.js"></script>
这是我的 jquery 代码:
$.getJSON(res/json/jsonFile.json, function(data){
var md5ModName = null;
for (var property in data) {
if (data.hasOwnProperty(property)) {
md5ModName = property;
}
}
localStorage['mainJSON'] = JSON.stringify(data[md5ModName]);
});
您的帮助将不胜感激:D
【问题讨论】:
-
日志中有错误吗?尝试使用 jsconsole.com 并将 $("something") 之类的命令发送到您的设备,看看它是否工作。
-
不知何故,上面的 jquery 代码不起作用。我尝试运行纯 javascript 代码,并且在 ipad 上运行良好。