Home > Web Front-end > JS Tutorial > Jquery Ajax Learning Example 3 Make a request to WebService and call the method to return data_jquery

Jquery Ajax Learning Example 3 Make a request to WebService and call the method to return data_jquery

WBOY
Release: 2016-05-16 18:32:15
Original
1218 people have browsed it

1. WebService.asmx
Process business data and generate weather data in the GetWhether method for JqueryRequest.aspx to call. The code is as follows:

Copy code The code is as follows:

[System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService {
public WebService ( ) {
// If using designed components, uncomment the following lines
// InitializeComponent();
}
[WebMethod]
public string GetWhether(string cityId)
{
Random r = new Random();
int degree = r.Next(100);
string wInfo = string.Format("Today {0}'s temperature is {1} degrees", cityId, degree);
return wInfo;
}
}

2. AjaxRequest.aspx
Request GetWhether(string cityId) of WebService.asmx by clicking the button Method to obtain weather data. The code is as follows:
Copy code The code is as follows:











< ;input type="text" name="Text2" id="Text2"/>


style="width:55px; height:20px;" />


sd
< /div>






Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template