I am having a problem on ajax calls. Each time I want to refresh or add more data in an ajax controlled area, I have to include some js files.
this is my usual script for submiting data
<script type="text/javascript">
function ajax_loader_order(x, y) {
$.getScript("js/plugins.js");
$.getScript("js/scripts.js");
req = $.ajax({
type: "GET",
url: "products.php?order=" + y + "&orderud=" + x,
datatype: "html",
success: function(data){
$('#container').html(data);
$('html, body').animate({scrollTop: $("#main").offset().top}, 1000);
}
});
}
</script>
Loading those js files each time, makes the website heavier and slower.
Is there a way with which I can load those js files on first load and every time I call this ajax function, to be included?
Thank you in advance
Add them after your ajax-script import in your html
Pseudocode:
<html>
<head>
<script src="ajax.js" />
<script src="js1.js" />
<script src="js2.js" />
</head>
<body>
</body>
</html>
or:
<html>
<head>
</head>
<body>
<script src="ajax.js" />
<script src="js1.js" />
<script src="js2.js" />
</body>
</html>