Javascript 为什么余烬数据认为save()失败了,而事实并非如此?
我有一个余烬模型,我正在保存到数据库中。当我打电话时Javascript 为什么余烬数据认为save()失败了,而事实并非如此?,javascript,ember.js,ember-data,Javascript,Ember.js,Ember Data,我有一个余烬模型,我正在保存到数据库中。当我打电话时 model.save().then(function () { alert('Everything worked.'); }, function () { alert('Save failed.'); }); 记录保存到数据库,对执行保存的API调用的网络请求以状态代码200和一个 { "id": 11, "send_date": "2014-12-01T23:20:31.821Z", "expiration_date"
model.save().then(function () {
alert('Everything worked.');
}, function () {
alert('Save failed.');
});
记录保存到数据库,对执行保存的API调用的网络请求以状态代码200和一个
{
"id": 11,
"send_date": "2014-12-01T23:20:31.821Z",
"expiration_date": "2014-12-08T06:00:00.000Z",
"message": "What is happening here",
"url": null,
"feature_id": null
}
控制台中不会出现任何错误。除了每次都调用拒绝处理程序警报“Save failed.”之外,所有操作都可以正常工作。从未调用成功处理程序。为什么?
编辑
传递给失败处理程序的原因是以下错误:
column: 22
line: 11256
message: "undefined is not an object (evaluating 'factory.typeKey')"
sourceURL: "http://localhost:8080/bower_components/ember-data/ember-data.js"
stack: "modelFor@http://localhost:8080/bower_components/ember-data/ember-data.js:11256:22
recordForId@http://localhost:8080/bower_components/ember-data/ember-data.js:10727:33
deserializeRecordId@http://localhost:8080/bower_components/ember-data/ember-data.js:11692:38
http://localhost:8080/bower_components/ember-data/ember-data.js:11670:30
http://localhost:8080/bower_components/ember-data/ember-data.js:9456:24
http://localhost:8080/bower_components/ember-data/ember-data.js:5295:37
http://localhost:8080/bower_components/ember/ember.js:14899:24
forEach@http://localhost:8080/bower_components/ember/ember.js:14741:18
forEach@http://localhost:8080/bower_components/ember/ember.js:14897:21
mapForEach@http://localhost:8080/bower_components/ember-data/ember-data.js:5302:29
eachRelationship@http://localhost:8080/bower_components/ember-data/ember-data.js:9455:49
normalizeRelationships@http://localhost:8080/bower_components/ember-data/ember-data.js:11666:28
didSaveRecord@http://localhost:8080/bower_components/ember-data/ember-data.js:11125:40
http://localhost:8080/bower_components/ember-data/ember-data.js:11905:28
tryCatch@http://localhost:8080/bower_components/ember/ember.js:45817:24
invokeCallback@http://localhost:8080/bower_components/ember/ember.js:45829:25
publish@http://localhost:8080/bower_components/ember/ember.js:45800:25
http://localhost:8080/bower_components/ember/ember.js:29071:17
invoke@http://localhost:8080/bower_components/ember/ember.js:634:22
flush@http://localhost:8080/bower_components/ember/ember.js:684:21
end@http://localhost:8080/bower_components/ember/ember.js:147:32
run@http://localhost:8080/bower_components/ember/ember.js:202:23
apply@http://localhost:8080/bower_components/ember/ember.js:18384:31
run@http://localhost:8080/bower_components/ember/ember.js:17001:19
success@http://localhost:8080/bower_components/ember-data/ember-data.js:1879:24
fire@http://localhost:8080/bower_components/jquery/jquery.js:2913:35
fireWith@http://localhost:8080/bower_components/jquery/jquery.js:3025:11
done@http://localhost:8080/bower_components/jquery/jquery.js:7400:25
http://localhost:8080/bower_components/jquery/jquery.js:7822:17"
编辑
我现在通过从Ember数据模型中删除一个belongsTo关系来修复这个错误。这种关系是为了我稍后将要实现的一个特性,所以我现在要删除它。我想当我到达那座桥时,我会穿过它。你能试试这个:},functionreason alertreason;}?JSON响应是否需要与模型类型同名?如果在devtools中启用“捕获异常时暂停”,则可能会在flagrante delicto中看到问题。