Reputation: 30238
I have a object .
reqeuest ={"_command":".login","username":"rahul","password":"12345"}
i want to add
{'on':{
login:function(){
console.log("logged in ");
},
error:function(){
console.log("oops error ");
}
}}
So it will become like it :
{
"_command":".login","username":"rahul","password":"12345",
'on':{
login:function(){
console.log("logged in ");
},
error:function(){
console.log("oops error ");
}
}}
what i tried is
request=$.extend(request,{'on':{
login:function(){
console.log("logged in ");
},
error:function(){
console.log("oops error ");
}
}});
or
hash.extend(request,{'on':{
login:function(){
console.log("logged in ");
},
error:function(){
console.log("oops error ");
}
}});
but it is not doing the what required what should i do ?
Upvotes: 0
Views: 450
Reputation: 97555
request.on = {
login: function() {
console.log("logged in ");
},
error: function() {
console.log("oops error ");
}
}
Upvotes: 1
Reputation: 18344
You should do this:
request["on"] = {
login:function(){
console.log("logged in ");
},
error:function() {
console.log("oops error ");
}
};
To test it, go to Script tab in firebug, and write 'request' on the 'Watch' tab. It's working. Cheers
Upvotes: 0