jquery ajax return: undefined

后端 未结 5 1962
暗喜
暗喜 2020-12-06 11:30

I\'m sure you know this problem, I\'m still trying to solve it for few days. I\'ve tried lots of stuff but no one worked:

Here is the code

function l         


        
5条回答
  •  攒了一身酷
    2020-12-06 11:48

    The problem here is that AJAX is asynchronous (it's what the first A stands for). This means that the function returns immediately; the success handler is only called when the request is successful. This means that lobbyLeader returns immediately after you have made your request, so returns nothing.

    If you have any code that needs to run after you have received the data, it must be placed in the success handler (or another AJAX event handler) or be invoked by it.

提交回复
热议问题