views:

24

answers:

1

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

alt text

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

alt text

I want to add some function to this object to call from everywhere easly in my files.

How can i achieve this?

Thanks...

+1  A: 

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!
   }
},
jAndy
But i want to add it before ajax to access in every where of my code.
uzay95
@uzuay95: I'm not aware of any way to include a `function()` into a JSON notation. 99% it's not possible.
jAndy