Is there a way in ASP.net to fetch data from database using Jquery Ajax Method. I know that i can easily access the data by creating a webservice and get it from there using Ajax. What I want to know is that how can I get the data from simple class methods which accesses the database rather than creating a webservice.
Is there a way in ASP.net to fetch data from database using Jquery(not using Webservices/WebMethods)
Asked
Active
Viewed 427 times
2 Answers
0
One way can be is to write a HTTPHandler and call that handler using Jquery to retrieve the data.

Deepansh Gupta
- 593
- 4
- 9
-
Which way will be more faster by the way. Calling Webservice or creating a HttpHandler? – Zohaib Ahmed Shakir Aug 20 '12 at 18:15
-
Well I am not sure too sure about it but I do not think of any considerable difference in the responsiveness of the two. – Deepansh Gupta Aug 21 '12 at 04:42
0
Check this out for a super-easy (lazy) way of doing a return straight from a public method defined in your aspx.cs file:
asp.net web forms json return result
Example shows putting [WebMethod]
and [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
attributes on top of the method allows you to call directly from ajax client side request. Worth considering securing this method though to prevent calls from elsewhere!

Community
- 1
- 1

Luke Baughan
- 4,658
- 3
- 31
- 54
-
But this ajax calls webservice/webmethod.I want to call the simple methods of class not webmethods. – Zohaib Ahmed Shakir Aug 21 '12 at 04:40