在后台引入 using System.Web.Services 命名空间

然后在编写web服务方法:

1     [WebMethod]
2     public static string GetData(string time, string targetColumn)
3     {
4         return "我是一个位于Aspx页面的WebService方法";
5     }

前端用Ajax的Post方法发送请求:

 1 $.ajax({
 2             type: "post",
 3             url: url,
 4             datatype: "json",
 5             contentType: "application/json",
 6             data: requestData,
 7             success: function (obj){
 8                   console.debug(obj);
 9             },
10             error: function (message) {
11             }
12         });

这样执行这个Ajax方法就可以用Aspx页面处理WebService请求了。

 

相关文章:

  • 2022-12-23
  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
  • 2021-05-30
猜你喜欢
  • 2022-12-23
  • 2022-02-15
  • 2021-08-14
  • 2022-12-23
  • 2021-08-15
  • 2021-11-21
相关资源
相似解决方案