aron
aron

Reputation: 2886

Best way to pass collections of data from C# to a jQuery?

This is a Asp.net 3.5 Web Application

I have a variety of data collections, like "Featured Blogs", "Event List", "Top Events" etc. About 5-10 in total.

I need this data to display on a variety of templates (same domain - no cross domain issues)

I do not want to force the designers to learn C#, instead I'd like them to just use jQuery to get the data and display it on a page.

What's the best implementation to support this?

  1. Use ASMX Web Service to return serialized object collections of data
  2. Create a .ashx handler for all 10 collections (seems a bit inefficient)
  3. Create a asp.net web form that accepts a query string (for the collection type) then returns a pure XML doc

Thanks for your help!

Upvotes: 0

Views: 177

Answers (1)

SipSop
SipSop

Reputation: 42

Yes, while I love xml to and completely believe in the need for a uniform manner of transferring data between applications that aren't inherently woven together...json is the easiest way to transfer data to jquery/javascript on the client side. The find() function makes xml parsing pretty darn easy to use but jquery has built in $.getJSON and $.parseJSON methods. Alot of jquery plugins/widgets also use json by default ie DataTables ( all though you can change this too if you like ). Overall if you are trying to simplify things for them, JSON is probably your best bet.

Upvotes: 1

Related Questions