Why does JQuery.getJSON() have a success and a done function?

后端 未结 2 1425
独厮守ぢ
独厮守ぢ 2020-12-15 22:33

The JQuery documentation for getJSON shows an example of:

var jqxhr = $.getJSON( \"example.json\", function() {
  console.log( \"success\" );
})
  .done(func         


        
2条回答
  •  伪装坚强ぢ
    2020-12-15 23:29

    They are the same thing. The done function is meant to work like Promise That way you can install handlers from the result of the ajax call. It even works if you call done after the asynchronous call finished (by storing the return value)

提交回复
热议问题