骨干model.save()调用没有任何错误或成功回调 [英] Backbone model.save() not calling either error or success callbacks

查看:279
本文介绍了骨干model.save()调用没有任何错误或成功回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更新数据库的记录,所以我定义数据模型和调用.save()方法。 PUT请求被触发,数据库条目更新。问题既不是成功或错误回调调用。可能是什么原因呢?

I'm trying to update a record in DB so I'm defining model with data and calling .save() method. The PUT request is triggered and the database entry is updated. The problem is neither success or error callbacks are called. What could be the cause?

sessionsModel.save({
    error: function() {
        alert('test');
    },
    success: function () {
        alert('test');
    }
});

编辑:请求返回的JSON对象

Request returns JSON object

推荐答案

就发现那里的问题解决了类似的问题。你必须把东西作为第一个参数(我把空,因为我的模型已经填充了明确的数据),并与回调的第二个对象。因此,像;

Just found similar problem where the issue was solved. You have to put something as first parameter (I put null since my model was already populated with data explicitly) and object with callbacks as second. So something like;

sessionsModel.save(null, {success:function() {} });

这篇关于骨干model.save()调用没有任何错误或成功回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆