简体   繁体   中英

asp.net -> javascript -> webservice -> Returning two classes from webservice call

Ok, I have a webservice that I created. Initially, I created a class, populated that class, and then returned that class to my javascript.

psuedocode

Return myClass.toarray

....Turns out I need to pass even more data back during this call. In turn I will have two classes that I need to pass back to my javascript. I tried putting them into an array and that wasn't working I also tried some other things that didn't really make a lot of sense. Any advice on this would be greatly appreciated, I am sure others have run into this type of situation previously. I know that you have to put them into an object but haven't figured out how to do this as of yet.

Basically, my question is, how do you pass two class objects back to javascript?

I think something along these lines may solve your problem

But even in this example the second class is like an inner class but you can get it easily on deserialization

http://blogs.msdn.com/b/rakkimk/archive/2009/01/30/asp-net-json-serialization-and-deserialization.aspx

I experienced this before. I decided not to return to class. Instead, I just try to combine both of my class into a single class. And then return the merged array. But this will depend on how you will use that array. If you want to separate them back. You may want to put special character as marker between the two stacks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM