I am sending an object that i generated within a class from the server as a result of web service call.
it is returning with __type and it's other attributes from server.
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!
}
},
精彩评论