日期:2014-05-17 浏览次数:20492 次
var chart;
function requestData() {
$.ajax({
type: "Post",
url: "Test1.aspx/DataBank",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
var x = (new Date).getTime(),
y = data.Data[0].linespeed;
chart.series[0].addPoint([x, y], true, true);
// call it again after one second
setTimeout(requestData, 1000);
},
error: function (err) {
alert(err + "调用后台程序出现错误,请尝试刷新!");
public string DataBank()
{
string json = "{\"Data\":[";
if (!flag)
{
json += "{\"linespeed\":\"" + "0" + "\"}]}";
}
else
{
json += "{\"linespeed\":\"" + iDataChannels.getLineSpeed().ToString() + "\"}]}";
}
return json;
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<!DOCTYPE html PUBLIC&nbs