<!DOCTYPE html>
<html lang="en-US">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<body>
<h1>jQuery ajax() Method</h1>
<p>Loading and using external javascript file.</p>
<button>Execute</button>
<script>
$(document).ready(function(){
$.ajax({
method: "GET",
url: "/script/alert-me.js",
cache: false,
dataType: "script"
});
$("button").click(function(){
myFunction();
});
});
</script>
<p><strong>Note</strong>: Script file used in this example is <a href="/script/alert-me.js" target="_blank">alert-me.js</a>. Here 'cache: false' tells the browser not to cache the requested page/data.</p> </body>
</html>