How do I put my return data from an asmx into JSON?
Posted
by jphenow
on Stack Overflow
See other posts from Stack Overflow
or by jphenow
Published on 2010-06-15T13:11:12Z
Indexed on
2010/06/15
18:12 UTC
Read the original article
Hit count: 217
I want to return an array of javascript objects from my asp.net asmx file. ie.
variable = [
{
*value1*: 'value1',
*value2*: 'value2',
...,
},
{
.
.
}
];
I seem have been having trouble reaching this. I'd put this into code but I've been hacking away at it so much it'd probably do more harm than good in having this answered.
Basically I am using a web service to find names as people type the name. I'd use a regular text file or something but its a huge database that's always changing - and don't worry I've indexed the names so searching can be a little snappier - but I would really prefer to stick with this method and just figure out how to get usable JSON back to javascript. I've seen a few that sort of attempt to describe how one would approach this but I honestly think microsofts articles are damn near unreadable.
Thanks in advance for assistance.
EDIT: I'm using the $.ajax() function from jQuery - I've had it working but it seems like I was doing it in bad practice not returning and using actual JSON. Previously I'd take a string back and insert it into html to use the variable it set - very roundabout.
© Stack Overflow or respective owner