我正在使用backbone.js 创建一个phonegap 应用程序。我正在保存到数据库并获得对象响应:
match_user.save({
'email':user.email,
'password':password,
'username':username,
'facebook_login':'yes',
'facebook_id':user.id
},
{
success:function(data){
console.log('data is ');
console.log(data);
console.log('data.username is ');
console.log(data.username);
console.log('data.password is ');
console.log(data.password);
console.log('JSON.stringify(data) is ');
console.log(JSON.stringify(data));
that.setSession(data);
},
error:function(){
console.log('in the error');
}
});
eclipse中console.log的输出是:
10-16 14:01:08.490: I/Web Console(10185): data is
10-16 14:01:08.490: I/Web Console(10185): [object Object]
10-16 14:20:51.500: I/Web Console(11297): data.username is
10-16 14:20:51.505: I/Web Console(11297): undefined
10-16 14:20:51.510: I/Web Console(11297): data.password is
10-16 14:20:51.510: I/Web Console(11297): undefined
10-16 14:01:08.495: I/Web Console(10185): JSON.stringify(data) is
{"first_name":"",
"last_name":"",
"email":"test@test.com",
"username":"user5654401630",
"password":"ipk9d",
"facebook_login":"yes",
"facebook_id":"5675685685"}
data.username、data.email 等都返回“未定义”,但是当我对对象进行字符串化时,我可以看到它们具有值...