when you try to do multiple things at a time but can't be sure which one is going to get done first ,  the logic required can get a little hairy,requiring a number of state variables

or a bunch of nested callbacks, luckily, as of jQuery  1.5

all jQuery Ajax methods return an object known as a Deferred that

and when used correctly,

it can greatly simplify your callback code .

$.when($.getJSON('level1.json'),$.getJSON('enemies.json'),$.getJSON('player.json'))

.then(function(level,enemies,player){

}).fail(function(){

});

相关文章:

  • 2022-03-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2022-12-23
  • 2022-02-21
猜你喜欢
  • 2021-05-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-30
  • 2022-12-23
  • 2021-05-15
相关资源
相似解决方案