ASP
版本為AJAX November CTP
三個示例分別為
一
注意要點
<system
<scripting>
<webServices>
<jsonSerialization>
<converters>
<add name=
<add name=
<add name=
</converters>
</jsonSerialization>
</webServices>
</scripting>
</system
WEB服務
using System;
using System
using System
using System
using System
using Microsoft
using System
/**//// <summary>
/// WS
/// </summary>
[WebService(Namespace =
[WebServiceBinding(ConformsTo = WsiProfiles
[ScriptService]
public class WS
public WS
//如果使用設計的組件
//InitializeComponent();
}
[WebMethod]
public string ServerTime()
{
return String
}
[WebMethod]
public DataTable GetDataTable()
{
DataTable dt = new DataTable(
dt
dt
dt
dt
dt
return dt;
}
}
WEB服務
using System;
using System
using System
using System
using System
using Microsoft
/**//// <summary>
/// WS 的摘要說明
/// </summary>
[WebService(Namespace =
[WebServiceBinding(ConformsTo = WsiProfiles
[ScriptService]
public class WS : System
public WS () {
//如果使用設計的組件
//InitializeComponent();
}
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public string HelloWorld(String query)
{
string inputString = Server
if (!String
{
return String
}
else
{
return
}
}
}
二
注意要點
需要使用的後台WebService的方法均設置在如下位置
<asp:ScriptManager ID=
<Services>
<asp:ServiceReference Path=
<asp:ServiceReference Path=
</Services>
</asp:ScriptManager>
Default頁面
<%@ Page Language=
<!DOCTYPE html PUBLIC
<html xmlns=
<head runat=
<title>Untitled Page</title>
<script language=
</script>
</head>
<body>
<form id=
<asp:ScriptManager ID=
<Services>
<asp:ServiceReference Path=
<asp:ServiceReference Path=
</Services>
</asp:ScriptManager>
<div>
<asp:Button ID=
<div id=
</div>
<div id=
<asp:DropDownList ID=
</asp:DropDownList>
</div>
</div>
</form>
</body>
</html>
三
注意要點
AJAX November CTP 需要用 eval() 方法將其轉換成一個DataTable對象(並且要裁掉最前面的
function dd()
{
WS
function(result)
{
alert(result);
}
);
WS
function(result)
{
alert(result);
var divTime = document
divTime
}
);
WS
function(result)
{
// 獲取到下拉框控件
var List = document
//AJAX November CTP 需要用 eval() 方法將其轉換成一個DataTable對象(並且要裁掉最前面的
var Text= result
var Table = eval( Text);
//AJAX December CTP 支持以下方法轉換
// var Table = Sys
//清除下拉框原有列表項
for (x=List
{
List
}
//從獲取的DataTable添加數據到下拉框列表項
for (x=
{
//獲取每一行
var Row = Table[x];
//創建一個列表項
var option = document
//列表項顯示文本賦值
option
//列表項選項值賦值
option
//判斷浏覽器類型
if ( window
List
else
List
}
}
);
}
示例代碼
From:http://tw.wingwit.com/Article/program/ASP/201311/21807.html