c#:webform,ajax

薛弘阔
2023-12-01

aspx:

var a=17;

$.ajax({
   type: "post",
   url: "Index.aspx/CsFun",
   contentType: "application/json; charset=utf-8",
   data: "{ a:'" + a + "'}",
   success: function (data) {
       var return_a = data.d;
   },
   error: function (err) {
       alert("error");
   }
});

Index.aspx.cs

[WebMethod]
public static object CsFun(string a){
   a+=1;
   return a;
}
 类似资料: