jQuery.getScript() Function

By: Dusty Arlia
Published on Monday, December 9, 2013, 08:14 AM
Last Updated on Saturday, July 11, 2015 at 9:07 PM
Total Updates: 3

The jQuery.getScript() function fetches a file of JavaScript code and processes it before invoking the callback function you specify. The JavaScript code can be same-origin or cross-origin. The XMLHttpRequest object can be used to load the script if the JavaScript file is from the same-origin. Otherwise, jQuery uses the <script> element. Here is an example:

jQuery.getScript(http://whiterootmedia.com/js/root_menu_script.js, function(){
//optional callback function
});

The JavaScript code is asynchronously downloaded and then executed in the global scope.

Comments:

Ad: