1
var COLLECTION = Backbone.Collection.extend({
    url: "example.com",
    sync: function(method, model, options){
        params = _.extend({
            type: "get",
            url: this.url,
            async: false,
            dataType: "jsonp",
            jsonpCallback : "jsonp_callback",
        },options);

        return $.ajax(params);
    },
    parse:function(response){
        console.log(response);
        return response;
    }
});
var a = new COLLECTION();
var b = new COLLECTION();
$.when(a.fetch(),b.fetch()).done(function(){ console.log('done'); });

我有两个问题:</p>

  1. 在同步函数中,$.ajax(params) 响应TypeError: a["reset"] is not a function@0.9.10
  2. 使用多个 collection.fetch 有时会发生a.fetch() or b.fetch() response parse error

谢谢!!

4

0 回答 0