Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Backbone.js fetch callback

I'm using Backbone.js and using fetch with options, but it doesn't seem to get the error or success callbacks, however data is being returned.

this.user.fetch({data: {username : this.username.val(), check : 'true'}}, {
    error: function(model, response) {
        console.log(response);
    },
    success: function(model, response)  {
        console.log(response);
    }
});

This is what I have setup, am I missing something? It never hits error or success, but it does do the ajax request and it's returning data.

Thank you!

like image 865
dzm Avatar asked Feb 21 '23 21:02

dzm


1 Answers

You're passing 2 separate arguments to fetch. Combine them into a single object with data, success, and error fields and it should work for you.

like image 177
x1a4 Avatar answered Feb 27 '23 11:02

x1a4