Should I format responses to ASMX web services for third party or client side AJAX?
Two parts of my question:
-
I need to format the web service responses to display on my web page. Should I use JavaScript to format the responses, or given that its .NET web service format responds as HTML and then just pushes it to the client?
-
If I use JavaScript to manipulate the response, what data types should I avoid in order to return from a .NET web service that may not "play well" with JavaScript?
Thank you for your help.
+2
source to share
1 answer
- It depends on the context. If you are returning a simple string to update
<span>
, I would use javascript to format it. If you are returning an RSS feed, I would format it server side. If you are using autocomplete for the textbox, it might be better to output the html using IHttpHandler. - If you are using JSON ( ScriptService ) web service methods, it doesn't matter what the .NET type is. The return value will be serialized as a JSON object .
Here's a great tutorial on Consuming ASP.NET JSON Web Services using jQuery .
+2
source to share