Setting local variable in a JavaScript callback function

后端 未结 5 1919
余生分开走
余生分开走 2021-01-02 11:33

I\'m relatively new to JavaScript and I thought I knew how callback functions worked but after a couple of hours of searching the web I still do not understand why my code i

5条回答
  •  误落风尘
    2021-01-02 11:56

    The first A in ajax is for Asynchronous, which means that by the time you are debugging the array, the result still hasn't been delivered. Array is undefined at the point of displaying it's value. You need to do the console.debug below array = data.

提交回复
热议问题