Passing Data From C# To Jquery
Solution 1:
you will need a REST service, which you will call from UI using jQuery.
your REST service will have to return a JSON result , otherwise it will make things more complicated.
in UI you will call the webservice using $.ajax() function.
once you got your results back from service , you can manipulate data in javascript and display it
Solution 2:
Probably the best way to do it is to create a web service (WCF or Asmx) for accessing data and let your client (Processing.js) fetch the data from there using JSON or XML once the page is loaded. Using such services with jQuery ajax
method is trivial, and you'll get cleaner MVC-like environment on the client side.
So, to reiterate:
- Create a web service using C# and your existing methods to retrieve the data from the DB and send it to client over HTTP
- Access this service using
ajax
or similar functions from jQuery core library. - Process the data on the client side and create the necessary DOM elements for fetched data.
Solution 3:
You need to make an Ajax call(Web Method) to the server to send/receive the data. Your .NET code in the back-end would do the connection to the database.
Post a Comment for "Passing Data From C# To Jquery"