jquery helper methods
dyanmically load scripts
by deshpandeakhil
HTML
<button id="loadScript">Dynamically load and execute script</button>
JavaScript
$(function() {
$("#loadScript").click(function() {
// getScript is an ajax request to download and execute the script
$.getScript("http://cloud.github.com/downloads/SteveSanderson/knockout/knockout-2.1.0.js", function(data, textStatus) {
alert(textStatus);
});
});
// catch error in case the request fails
$("#loadScript").ajaxError(function(event, jqXHR, ajaxSettings, thrownError) {
alert("Error: " + thrownError);
});
});