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
Post a Comment