Home  >  Article  >  Web Front-end  >  Jquery Ajax Learning Example 4 Makes a request to WebService and returns an asynchronous call of the entity object_jquery

Jquery Ajax Learning Example 4 Makes a request to WebService and returns an asynchronous call of the entity object_jquery

WBOY
WBOYOriginal
2016-05-16 18:32:141058browse
1. WebService.asmx:
Process business data and generate Person entity class data in the GetPerson method for JqueryRequest.aspx to call. The code is as follows:
Copy code The code is as follows:

 [WebMethod]
public Person GetPerson(string name, int age, string address)
{
Person p = new Person()
{
Name = name,
Age = age,
Address = address
};
return p;
}

2. Person.cs entity class:
Copy code The code is as follows:

public class Person
{
private string _name;
public string Name
{
get { return _name; }
set { _name = value ; }
}
private int _age;
public int Age
{
get { return _age; }
set { _age = value; }
}
private string _address;
public string Address
{
get { return _address; }
set { _address = value; }
}
}

3. AjaxRequest.aspx
By clicking the button, request the GetPerson(string name, int age, string address) method of WebService.asmx to obtain the Person entity data. The code is as follows:
Copy code The code is as follows:


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