Load javascript without caching using ajax request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadJS(file,CallBack){ | |
var xmlhttp=new XMLHttpRequest(); | |
var ts = "?"+new Date().getTime();// use timestamp for prevent caching | |
xmlhttp.open('GET', file+ts,true); | |
xmlhttp.onload=function(){ | |
if(xmlhttp.readyState==4 && xmlhttp.status==200){CallBack(xmlhttp.responseText);}; | |
}; | |
xmlhttp.send(); | |
}; | |
loadJS("//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.7.0/bootstrap-table.min.js",function(response){ | |
console.log(response,'loaded'); | |
eval(response); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment