以下骨干collection.fetch 代码因某种原因触发,出错,然后跳转到错误处理程序(如预期的那样),但我真的不知道错误处理程序参数是什么。触发错误时,模型、xhr 和选项参数未定义。我究竟做错了什么?
var onErrorHandler = function(model, xhr, options) {
alert(options);
};
that.collection = new MembersCollection([]);
that.collection.fetch({ success : onDataHandler, error: onErrorHandler, dataType: "jsonp" });
@muistooshort:我完全忘记了 js 参数,谢谢你的提示。
这是我发现的...
Arguments[0] = looks like its just the letter "d"
Arguments[1] = is an object. Has readyState, responseText, status, statusText
Arguments[2] = is an object. Exactly the same as [1]
状态 = 200,文本为“OK”。responseText 是我希望从 PHP 服务器模型接收到的确切 JSON 数据。
所以我想现在的问题是为什么 collection.fetch 方法将成功结果发送到错误处理程序?我不相信 fetch 回调中这些处理程序的顺序很重要。可以?