Asp.net&ajax&json-Dynamic Read data

Source: Internet
Author: User

Because before the WM Group made a delivery dashboard, about 3 weeks time,. NET also forget almost, Ajax and Highchart table is also learning, pretty laborious! Finally, I got it. Post a record.

1. foreground aspx page <Javascript> (the following AJAX code can be present and triggered in a JS event, which is included in the event code)

$.getjson ("Handler4.ashx", {"param": A, "param1": B}, function (data) {$.each (data, function (I, item) {    bar_version. Push (item["version"]);    Bar_value.push (item["Vamount"]);                   $.each (item, function (k, v) {                                                 });                       });

Param and param1 Pass the values of A and b into the background.

2. Ashx.cs-handler

string param = httpcontext.current.request["param"];

Pass the Param value into the handler CS background and serialize a list parameter JSON (using the Newtonsoft package)

stringStrjson = Newtonsoft.Json.JsonConvert.SerializeObject (_list);
Context. Response.Write (Strjson);

For more information about Newtonsoft:

Http://www.newtonsoft.com/json

3. incoming background JSON data to the foreground

$.getjson ("Handler4.ashx", {"param": A, "param1"function  (data) {// The Red data variable is a variable Strjson function from the background JSON format   ///through each function, the JSON-formatted data is read out.    Bar_version.push (item["version"]);    Bar_value.push (item["Vamount"]);           function ( K, v) {                                                 });                       });          

Asp.net&ajax&json-Dynamic Read data

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.