1. WebService.asmx
Process business data and generate weather data in the GetWhether method for JqueryRequest.aspx to call. 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:
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