Without using any third party tools, what is the ideal way to provide JSON response data?
I was thinking of having an ASPX application page to just return the json string response. Any ideas?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The simplest way is to create a method with the
[WebMethod]attribute, and the response will automatically be JSON serialized. Try it yourself:And the Ajax call URL would be:
Edit:
To pass parameters, just add them to the function:
I’m using jQuery so the
data:object would be set with:Also note that the JSON object returned will look like this:
The extra
"d"in the data is explained here: http://encosia.com/2009/02/10/a-breaking-change-between-versions-of-aspnet-ajax/