日期:2014-05-17 浏览次数:20510 次
<script type="text/javascript">
$(document).ready(function checkAjax() {
$.ajax({
type: "post",
url: "HighCharts.aspx/DataBank",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
data = data[1].price;
alert(data);
},
error: function (err) {
alert(err + "调用后台程序出现错误,请尝试刷新!");
}
}
)
})</script>
public static string DataBank()
{
// work=new WorkOrderMachineOnlyOnce();
// iData=(IDataChannels)work;
string ajaxTest = "hello";
string json = "[";
json += "{\"linespeed\":\"" + ajaxTest+ "\"},{\"price\":\"";
json += ajaxTest + "\"}]";
return json;
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.4.1.min.js" type="t