Saving the base: "success" is not triggered

I am working on my first major project using Backbone. I have a Backbone view called in the SignUpViewfollowing way:

register: function(){
    this.model.save({
        email: $('#email').val(),
        password: $('#passwd').val()
    },{
        success: function(model, response){
            console.log("Registration succeeded, congrats!");
            window.location.hash = '';
        },
        error: function(model, response){
            console.log("Registration failed, reason = "
                + response.responseText 
                + " (status "+response.status+")");
        }
    });
    return false;
}

However, whenever I run it, only the callback is called error. This leads to strange behavior such as console logging

Registration failed, reason = Registration succeeded (status 200)

("Successful registration" is sent from the server after successful registration, otherwise he would say "Missing parameter" password "or" Invalid email format "or similar.)

, 200 , , "error". , , , - , , .

+4
1

, , , JSON . JSON (, Registration succeeded), .

{"ok":"Registration succeeded"}

, .

+5

All Articles