i) 具备这个时间。
public class HomeController : Controller
{
public int count = 0;
public ActionResult Index()
{
Timer timer = new Timer();
timer.Interval = 1000;
timer.Elapsed += new ElapsedEventHandler(onTimer);
timer.Start();
return View();
}
public void onTimer(Object source, ElapsedEventArgs e)
{
count++;
}
[HttpPost]
public JsonResult CheckStatus()
{
return Json(count);
}
我认为:
<script type="text/javascript">
$(function () {
// poll every 5 seconds
setInterval( checkStatus() , 3000);
});
function checkStatus() {
$.ajax({
url: Home/CheckStatus ,
type: POST ,
dataType: json ,
success: function (xhr_data) {
document.getElementById("test").innerText = xhr_data;
}
});
}
为什么它只向我(当跑时)展示吗? 为什么没有我:0,1,2等?