使用jQuery延迟加载js文件

来源:互联网 发布:linux 脚本usleep 编辑:程序博客网 时间:2024/05/18 00:15
//异步加载js文件并调用函数function delayCall(calledFunction, funcParams, jsUrl){if (eval('typeof '+calledFunction) == 'function') {eval(calledFunction+'(funcParams)');} else {jQuery.ajax({type: 'GET',url: jsUrl,data: {},dataType: 'script',cache: true,async: true,success: function () {eval(calledFunction+'(funcParams)');}});}}//同步加载js文件function syncLoad(checkFunction, jsUrl){if (eval('typeof '+checkFunction) != 'function') {jQuery.ajax({type: 'GET',url: jsUrl,data: {},dataType: 'script',cache: true,async: false,});}}


0 0
原创粉丝点击