MVC4 + highcharts Real-time online graph

Source: Internet
Author: User

Remember: 1.ajax calls to the asynchronous processing of data methods cannot be the primary method,

For example public ActionResult Index ()

{

Return view ()

}

[HttpPost]

Public ActionResult GetIndex ()

{

list<gm_group> data = new list<gm_group>
{
New Gm_group{id=1,name= "123"},
New gm_group{id=2,name= "456"},
};
return View ();
return Json (data, jsonrequestbehavior.allowget);//Foreground Ajax if it's a get, use this sentence

}

2:ajax syntax

Get background data by default on the day of loading
$ (document). Ready (function () {
$.ajax ({
Type: "Post",
URL: "Todayrealonlines",
DataType: "JSON",
Data: $ ("form"). Serialize (),//form serialization, if not serialized, return when it is directly in the page output JSON content, Ajax will not operate it
Success:function (data) {
data = eval (data);
var x = new Array ();
var y = new Array ();
for (var i = 0; i < data.length; i++) {
X[i] = Data[i].onlinetime;
Y[i] = Data[i].onlinecount;
}
Show (x, y);
},
Display Error
Error:function (Err) {
Alert ("The query failed, please try refreshing!") ");
}
}), 30000//page timed Refresh
})

3. Page Query button cannot be submit, should use button

4.

MVC4 + highcharts Real-time online graph

Related Article

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.