Passing data from C # to jQuery

Looking for some tips on how best to deal with the following situation, I'm the only programmer.

I am currently developing a C # Winforms application, new functionality I am writing allows the user to sketch Processing.js for data analysis purposes. I created the Processing.js IDE (working) that allows the user to write and test Processing.js thumbnails and HTML code.

The last piece of the puzzle is to pull the data from the database into sketches.

What's the best approach I should be researching to achieve this?

The data is stored in a Firebird database and accessed / managed using NHibernate. Data access is written in C #, methods at the data access layer return objects from the database that are used throughout the application. Ideally, I would like to access this data to create machining sketches.

The IDE Processing.js also includes the jQuery library. How can I get database data using jQuery. Can I call C # methods located at the data access layer.

Any advice is appreciated.

+3


source to share


3 answers


  • you will need a REST service which you will call from the UI using JQuery.

  • your REST service must return a JSON result, otherwise it will complicate things.

  • in the UI you will call the webservice using the $ .ajax () function.

    after you get your results back from work you can manipulate the data in javascript and display it



+1


source


Probably the best way to do this is to create a web service (WCF or Asmx) to access the data and let your client (Processing.js) fetch data from there using JSON or XML after the page has loaded. Using services like this with the jQuery method is ajax

trivial and you end up with a clean environment with a MVC-like client-side environment.

So, I repeat:



  • Create a web service using C # and existing methods to fetch data from DB and send it to client over HTTP
  • This service can be accessed using ajax

    or similar functionality from the core jQuery library.
  • Process the data on the client side and create the required DOM elements for the retrieved data.
0


source


You need to make an Ajax call (web method) to the server to send / receive data. Your .NET code in the background will connect to the database.

0


source







All Articles