javascript - $.getScript for every element of an array -


the var json.script array. every element path script, want load via $.getscript. should - don't know how loop array every array-element:

$.when(     $.getscript( json.script ),     $.getscript( json.script ),     $.getscript( json.script ),     $.getscript( json.script ),     $.deferred(function( deferred ){         $( deferred.resolve );     }) ) .done(function( script, textstatus ) { success(json); }) .fail(function( jqxhr, settings, exception ) { errormessage( exception ); }); 

you can use .map call $.getscript on each element of array. can apply $.when result of this:

$.when.apply(null, json.script.map(function(e) {     return $.getscript(e); })) .done(function( script, textstatus ) { success(json); }) .fail(function( jqxhr, settings, exception ) { errormessage( exception ); }); 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -