大佬教程收集整理的这篇文章主要介绍了jQuery getScript加载与执行,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
“一旦脚本被加载但不一定执行,回调就会被触发.”
但在我的测试中,似乎不是真的.对于主机页面:
var startTime = new Date(); $.getScript("test.js") .done(function( script,textStatus ) { console.log( textStatus ); console.log( "Done callBACk execuTing Now.") }) .fail(function( jqxhr,setTings,exception ) { console.log("error." ); });
加载以下“test.js”脚本,将uI绑定5秒钟:
console.log("ajaxed script starTing to execute."); var newTime = new Date(); while (newTime - startTime < 5000) { newTime = new Date(); } console.log("elapsed time",newTime - startTimE); console.log("ajaxed script finished execuTing.");
导致FF& amp;铬:
ajaxed script starTing to execute. elapsed time 5000 ajaxed script finished execuTing. success Done callBACk execuTing Now.
换句话说,成功回调在加载和执行加载的脚本之前不会触发.这似乎是因为在jQuery source中,globalEval函数立即调用脚本:
converters: { "text script": function( text ) { jQuery.globalEval( text ); return text; } }
文件错了吗如果它们是正确的,那么在执行脚本之前,什么特定情况下成功回调会触发?
以上是大佬教程为你收集整理的jQuery getScript加载与执行全部内容,希望文章能够帮你解决jQuery getScript加载与执行所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。