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