Home  >  Article  >  Web Front-end  >  Jquery ajax传递复杂参数给WebService的实现代码_jquery

Jquery ajax传递复杂参数给WebService的实现代码_jquery

WBOY
WBOYOriginal
2016-05-16 18:03:44904browse

Entity:

复制代码 代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
namespace Entity
{
[DataContract]
public class User
{
[DataMember]
public string Name
{
get;
set;
}
[DataMember]
public int Age
{
get;
set;
}
}
}

WebService:
复制代码 代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Entity;
namespace JQuery.Handler
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class UserService1 : System.Web.Services.WebService
{
[WebMethod]
public string ComplexType(User hero,List users)
{
return hero.Name + " has " + users.Count + " people!";
}
}
}

Html:
复制代码 代码如下:



Ajax







Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn