extjs REST api 保存数据
我正在使用休息服务(POST)将用户保存到服务器的数据库中。用户被发送并保存在我的数据库中,但响应未正确解释并且执行停止。一遍又一遍地寻找解决我的问题的方法,但似乎找不到任何解决方案。
这是我的控制器代码:
addUser: function () {
var form = this.addUserWindow.down('form').getForm ();
if (form.isValid()) {
var user = new AP.model.User(form.getValues ());
if ( user.validate () ) {
user.save ({
success: function() {
this.addUserWindow.destroy();// destroys this window
this._reloadStore ();// reloads a grid
}
});
}
}
}
在 user.save 方法上,即使发布数据并保存记录并返回,执行也会停止,如下所示:
{"data":{"username":"xyz","email":"[email protected]","password":"abcd","id":"1"},"success":true,"error":null,"errors":[]}
错误说:
Uncaught TypeError: Cannot read property 'data' of undefined
callback ext-all-debug.js:26824
Ext.define.processResponse ext-all-debug.js:26044
(anonymous function) ext-all-debug.js:26240
Ext.apply.callback ext-all-debug.js:5140
Ext.define.onComplete ext-all-debug.js:20950
Ext.define.onStateChange ext-all-debug.js:20912
(anonymous function)
I'm saving a user to my server's database using rest services (POST). The user gets sent and saved allright in my db but the response is not interpreted right and the execution stops. Searched over and over again for a solution to my problem but can't seem to find any.
Here's my controller code:
addUser: function () {
var form = this.addUserWindow.down('form').getForm ();
if (form.isValid()) {
var user = new AP.model.User(form.getValues ());
if ( user.validate () ) {
user.save ({
success: function() {
this.addUserWindow.destroy();// destroys this window
this._reloadStore ();// reloads a grid
}
});
}
}
}
On user.save method the execution stops even though the data is posted and record saved and returned like this:
{"data":{"username":"xyz","email":"[email protected]","password":"abcd","id":"1"},"success":true,"error":null,"errors":[]}
The error says:
Uncaught TypeError: Cannot read property 'data' of undefined
callback ext-all-debug.js:26824
Ext.define.processResponse ext-all-debug.js:26044
(anonymous function) ext-all-debug.js:26240
Ext.apply.callback ext-all-debug.js:5140
Ext.define.onComplete ext-all-debug.js:20950
Ext.define.onStateChange ext-all-debug.js:20912
(anonymous function)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
返回记录:
其中
“data”
应该是阅读器中定义的根属性。The return record:
where
"data"
should be the root property defined in the reader.