ajax - Javascript Variable Showing undefined -


i have global javascript array , able call values @ beginning of function after that, when alert leaders[i], shows undefined: appears problem occurs when there 2 ajax calls nested in each other, js cannot seem find values in array.

js

function getleaders(bool) {     var leaders = new array();     leaders.push('444');     leaders.push('111');     $.ajax({         url: 'url',         crossdomain: true,         type: 'post',         data: {             'clubid': curclub         },         success: function (data) {               (var = 0; < leaders.length; i++)               {                   alert(leaders[i]); <===== working fine here                   $.ajax({                        url: 'someurl',                        crossdomain: true,                        type: 'post',                        data: {                            'id': leaders[i] <====== works here                        },                        success: function(data3) {                            alert(leaders[i]);      <======= undefined here                            var json3 = jquery.parsejson(data3);                        }                 });             }            }       });      }; 

since call asynchronous value of more leader.length time call returns. accessing index out-of bounds.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -