jQuery并不总是加载 [英] jQuery doesn't always load
问题描述
好的,所以我有这个页面里面有很多javascript / jQuery。现在的问题是它有时会加载,有时却没有。经过几次刷新后,它最终会恢复正常。该页面仍然是原型,用户尚无法查看,但我注意到问题有时会跨越整个网站。有谁知道如何解决这一问题?登录脚本基于jQuery / Ajax,联系表单基于jQuery,许多其他设计相关的东西也基于jQuery。没有它,我有一个很大的问题。所有函数都在文档就绪函数内,所有scrypt标签都使用新的html 5`async =async。
Okay so I have this page with quite a lot of javascript/jQuery in it. Now the problem is that it sometimes loads and it sometimes doesn't. It eventually gets working after a few refreshes. The page is still a prototype and it's not yet viewable to the users, but i noticed that the problem sometimes spans across the whole website. Does anyone know how to fix this? The login script is jQuery/Ajax based, the contact form is jQuery based and a lot of other design related stuff are based on jQuery as well. Without it, i have a big problemo. All functions are inside document ready functions and all the scrypt tags are using the new html 5 `async="async".
推荐答案
包含 jQuery
后备:
<script type="text/javascript">
if (typeof jQuery == 'undefined')
document.write(unescape("%3Cscript src='/path/jquery' type='text/javascript'%3E%3C/script%3E"));
</script>
另外,因为你使用的是 async = async $ c脚本下载后需要运行代码的$ c>属性,即:
document.load
Also, since you're using the async=async
attribute you need to run your code when the scripts have finished downloading i.e.: document.load
这篇关于jQuery并不总是加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!