Can't access global variable in jQuery $.get within function

后端 未结 3 1803
甜味超标
甜味超标 2021-01-18 10:25

Below is some code I\'m having trouble with. Basically, I\'m defining an empty array as a global variable (var playlist = []) and then trying to add elements to it within a

3条回答
  •  一整个雨季
    2021-01-18 10:45

    .get is asynchronous, hence the need to provide a callback function. While your get is still in process you are trying to use the array, probably before it's actually been populated.

提交回复
热议问题