Deferred versus promise

前端 未结 2 1351
既然无缘
既然无缘 2020-12-04 06:13

What is the difference between Deferred and Promise other than the jQuery versions?

What should I use for my need? I only want to call the fooExecute()

2条回答
  •  醉话见心
    2020-12-04 06:38

    A promise is something you can set on a deferred object that executes when the deferred collection is complete.

    Example from the jQuery documentation:

    
    
    
      
      
    
    
    
    
    

    Ready...

    Here it is in JSFiddle

    This runs a function on each div and executes the .promise code when all .each executions are complete.

提交回复
热议问题