Hello...for example:
script1.js
- function firstLoad() {
- loadScript('second.js');
- }
and the code which is executing:
- var loadScript = function(file, success) {
- $.ajax(file, {
- dataType: 'script',
- async: false,
- success: function() {
- if (success) {
- window[success]();
- }
- }
- });
- }
- loadScript('first.js', 'firstLoad');
- loadScript('third.js', thirdLoad');
so the problem is that in some cases success function is loaded after the first and third js file are loaded...and are loaded in that form:
1. first.js
2. third.js
3. second.js
maybe exists another ways to load and execute the loaded functions before another syncronous request is started?