Use Ajax to get and then run a JavaScript - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:ajax

Description

Use Ajax to get and then run a JavaScript

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $.ajax({url: "demo_ajax_script.js", dataType: "script"});
    });/*  ww  w  .  j a  va  2s . c  o  m*/
});
</script>
</head>
<body>

<button>Use Ajax to get and then run a JavaScript</button>

</body>
</html>

Related Tutorials