开发者

how can i add a function to json object which has __type attribute?

I am sending an object that i generated within a class from the server as a result of web service call.

how can i add a function to json object which has __type attribute?

it is returning with __type and it's other attributes from server.

alt text

I want to add some function to this object to ca开发者_JAVA技巧ll from everywhere easly in my files.

How can i achieve this?

Thanks...


Well if I get you right, you want to add a function() to the returned object. You can't add a function serverside, since you are not allowed to transfer executable javascript code within a JSON object.

So you would have to add a method/property to that object after your client has created your javascript object. like

success: function(data){
   data.my_new_method = function(){
      // yay!
   }
},
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜