jquery uses ajax to call background method instance_jquery
- WBOYOriginal
- 2016-05-16 17:24:38902browse
Syntax:
$(function(){
var callback = function(r){ //r represents the data returned by the background data.
}
$.get("",callback); //Write the path of the method in quotation marks
}) ;
In this way, the data obtained by the background method can be displayed on the html front-end.
The following is a js and background method written at work:
js:
$(function(){
var callback = function (r) {
var data = "
; r.length - i - 1].CustomerName "
";
}
$("#01_list").html(data2 (t_data2.length > 0 ? t_data2.substr(6, t_data2.length - 6) : "") "
");
}
$.get("/activity/trycompany", callback);
});
Backend code (mvc4):
var list = vlist.ToList().ConvertAll(s =>
-dd HH:mm") : "" };
});
return Json(list, JsonRequestBehavior.AllowGet); Call, traverse, and then display on the front end.
A very simple example, there must be an easier way, I’ll dig into it later.