jQuery.getScript加载同域JS的代码
程序员文章站
2023-11-08 14:31:22
解决方法,用以下方法加载js:
代码如下:
var loadscript = function(url, callback, charset){
var head = document.getel...
解决方法,用以下方法加载js:
代码如下:
var loadscript = function(url, callback, charset){
var head = document.getelementsbytagname('head')[0];
var script = document.createelement('script');
if(charset){
script.charset = charset;
}
script.src = url;
if(!callback){
return;
}
script.onload = script.onreadystatechange = function(){
if(!this.readystate || this.readystate==='loaded' || this.readystate==='complete'){
callback();
}
};
head.appendchild(script);
};