15

I need to call a fetch with a synchronous call, I know with jquery ajax I can use {async: false} can I pass this option to fetch function ?

4

2 回答 2

32

所以简短的回答是肯定的,您可以使用参数简单地调用 fetch 函数

{async:false}.
于 2013-08-26T18:11:27.110 回答
14

实际上主干获取方法在内部调用了ajax。因此,您可以将任何 ajax 选项传递给主干 fetch 方法。

collection.fetch({
  // ajax options
   async: false, // by default it is true
   success: function(collection, response, options){
             console.log("success")
          },
   error: function(collection, response, options){
             console.log("error")            
          }
});
于 2014-05-06T06:15:26.407 回答