2023年7月9日发(作者:)
jQuery使用Ajax方法调用WebService
在这里将jQuery使用Ajax 调用WebService 的几个常用的方法做了一个整理,提供给正在找这方面内容的博友,希望能给学习jQuery的朋友一点帮助。代码直接复制即可。
代码
using System。
using c。
9 / 13 using 。
using 。
using es。
using 。
namespace ng
{
///
/// WebService1 的摘要说明
///
[WebService(Namespace = "">]
[WebServiceBinding(ConformsTo =
rofile1_1>]
[xItem(false>]
// 若要允许使用 AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
[Service]
public class WebService1 :
vice
{
///
/// 无参数
///
///
[WebMethod]
public string HelloWorld(>
{
return "Hello World "。
}
10 / 13 ///
/// 带参数
///
///
///
///
///
///
[WebMethod]
public string GetWish(string value1, string value2,
string value3, int value4>
{
return ("祝您在{3}年里 {0}、{1}、{2}", value1, value2, value3, value4>。
}
///
/// 返回集合
///
///
///
[WebMethod]
public List
{
List
while (i >= 0>
{
(i-->。
}
11 / 13 return list。
}
///
/// 返回一个复合类型
///
///
[WebMethod]
public Class1 GetClass(>
{
return new Class1 { ID = "1", Value = "牛年大吉" }。
}
///
/// 返回XML
///
///
[WebMethod]
public DataSet GetDataSet(>
{
DataSet ds = new DataSet(>。
DataTable dt = new DataTable(>。
("ID",
e("">>。
("Value",
e("">>。
12 / 13 DataRow dr = (>。
dr["ID"] = "1"。
dr["Value"] = "新年快乐"。
(dr>。
dr = (>。
dr["ID"] = "2"。
dr["Value"] = "万事如意"。
(dr>。
(dt>。
return ds。
}
}
//自定义的类,只有两个属性
public class Class1
{
public string ID { get。 set。 }
public string Value { get。 set。 }
}
}
13 / 13
发布者:admin,转转请注明出处:http://www.yc00.com/xiaochengxu/1688851066a176570.html
评论列表(0条)