How do I trigger the success callback on a model.save()?

前端 未结 8 1014
粉色の甜心
粉色の甜心 2020-11-28 23:06
this.model.save({
  success: function(model, response){
    console.log(\'success\');
  },
  error: function(){
    console.log(\'error\');
  }
})

8条回答
  •  盖世英雄少女心
    2020-11-28 23:23

    For some unknown reason, none of the above method worked for me. The api only was not hit in my case.

    But later while searching on this, I bumped into this link, where some one had tried null instead of {} as the first parameter.

    this.model.save(null, {
        success: function (model, response) {
            console.log("success");
        },
        error: function (model, response) {
            console.log("error");
        }
    });
    

    so, this worked for me. Hope this helps you too.

提交回复
热议问题