通过某些函数进行哈希扩展
我有一个对象。
reqeuest ={"_command":".login","username":"rahul","password":"12345"}
我想添加
{'on':{
login:function(){
console.log("logged in ");
},
error:function(){
console.log("oops error ");
}
}}
所以它会变成这样:
{
"_command":".login","username":"rahul","password":"12345",
'on':{
login:function(){
console.log("logged in ");
},
error:function(){
console.log("oops error ");
}
}}
我尝试过的是
request=$.extend(request,{'on':{
login:function(){
console.log("logged in ");
},
error:function(){
console.log("oops error ");
}
}});
或者
hash.extend(request,{'on':{
login:function(){
console.log("logged in ");
},
error:function(){
console.log("oops error ");
}
}});
但它没有做所需的事情我应该做什么?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该这样做:
要测试它,请转到 firebug 中的“脚本”选项卡,然后在“监视”选项卡上编写“请求”。它正在发挥作用。
干杯
You should do this:
To test it, go to Script tab in firebug, and write 'request' on the 'Watch' tab. It's working.
Cheers