Reputation: 6938
I have a success callback function which returns the following always :
{"ss":0,"me":"Invalid Username or Password"}
success :function(result){
console.log("RESULT : "+result.ss);
}
But this always ends up as undefined.. If i print the result, i get the above array. If i return result.ss or result.me i get undefined.
I think there is a very silly reason for why this is happening, but i cannot get my head around.
Backbone View(removing other codes) :
this.model.save({un : username,pd : password, ky : ky}, {
success :function(result){
console.log("RESULT : "+result.ss);
return false;
if(result.ss==1){
$("#login_message").addClass('alert-success');
var userType = result.pp.ut;
if(userType=="T"){
window.location.href="trainer/index.html";
}else if(userType=="C"){
window.location.href="clients/index.html";
}else if(userType=="A"){
window.location.href="admin/index.html";
}else{
return false;
}
return false;
}
if(result.ss==0){
console.log(result);
$("#login_message").addClass('alert-error');
console.info("Failed to Log In.");
}
return false;
},
error: function(res){
console.log(res);
return false;
}
});
return false;
Upvotes: 0
Views: 96
Reputation: 3458
Backbone success function has the result parameter after model parmeter, you are using model instead of result.
success:function(model, response){}
Upvotes: 1