Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Load javascript without caching using ajax request
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