so right now I have this code. on ajax success it dynamically loads my js files. but my point here is.. is there any way where I can load them all at once without typing them one by one? by means like folder/*.js then it will load all js files inside that folder. here is my example code.
JS
$(document).ready(function() {
$(document).on("click", "a[rel=tab]", function(e) {
// e.preventDefault();
$e = $(e);
pageurl = $(this).attr('href');
$.ajax({
url: pageurl + '?rel=tab',
success: function(data) {
var head = document.getElementsByTagName("head")[0];
var jquery = document.createElement("script");
jquery.type = "text/javascript";
jquery.src = base_url + "/assets/bower_components/datatables.net/js/jquery.dataTables.min.js";
head.appendChild(jquery);
var js = document.createElement("script");
js.type = "text/javascript";
js.src = base_url + "/assets/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js";
head.appendChild(js);
var jsn = document.createElement("script");
jsn.type = "text/javascript";
jsn.src = base_url + "/assets/js/newscript.js";
head.appendChild(jsn);
jsn.onload = function() {
$('#inside').html(data);
}
}
});
//to change the browser URL to 'pageurl'
if (pageurl != window.location) {
window.history.pushState({ path: pageurl }, '', pageurl);
}
return false;
});
$(window).bind('popstate', function() {
$.ajax({
url: location.pathname + '?rel=tab',
success: function(data) {
$('#inside').html(data);
}
});
});
});