开发者

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

开发者 https://www.devze.com 2023-03-25 05:15 出处:网络
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.

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开发者_如何学Go.net web form that accepts a query string (for the collection type) then returns a pure XML doc

Thanks for your help!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消