jQuery 的 .getScript()...我做错了什么?
我正在使用 Phonegap 编写 iPhone 应用程序。我有本地 .html
和 .js
文件。以下内容位于我的 index.html
文件中:
function onBodyLoad() {
document.addEventListener("deviceready", deviceReady, false);
}
function deviceReady() {
$.getScript("js/order.js");
}
我研究了又研究,但就是不明白为什么我的“order.js”文件没有被 $.getScript 调用方法。有什么想法吗?或者是否有其他方法可以在我的
index.html
的 deviceReady 函数中调用此 .js
文件?
I'm programming an iPhone app with Phonegap. I have local .html
and .js
files. The following is in my index.html
file:
function onBodyLoad() {
document.addEventListener("deviceready", deviceReady, false);
}
function deviceReady() {
$.getScript("js/order.js");
}
I researched and researched, but just can't figure out why my "order.js" file isn't getting called by the $.getScript
method. Any ideas? Or is there any other way to call this .js
file within the deviceReady function in my index.html
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我来说,以下解决方案非常有效。
添加一个使用 ajax 并缓存加载脚本的自定义 jQuery 函数:
导入脚本并可选择处理
done
和fail
:< /p>就是这样:)
更多信息可以在此处找到。
For me the following solution worked very well.
Add a custom jQuery function that uses ajax and caches the loaded script:
Import the scripts and optionally handle
done
andfail
:Thats it : )
More information may be found here.