标签:pre err ajax div webform eth erro pen web
调用含参方法:
$("#btn").click(function () { $.ajax({ type: "Post", url: "WebForm1.aspx/GetStr", data: "{‘str‘:‘aaa‘,‘str2‘:‘bbb‘}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { alert(data.d); }, error: function (err) { alert(err); } }); return false; });
.cs:
[WebMethod] public static string GetStr(string str1, string str2) { return str1 + str2; }
调用无参方法:
$(function () { $("#btGetDataTable").click(function () { $.ajax({ type: "Post", url: "WebForm1.aspx/Traverse", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { $("#table1").append(data.d); }, error: function (err) { alert(err); } }); return false; }); })
.cs:
[WebMethod] public static string Traverse() { }
标签:pre err ajax div webform eth erro pen web
原文地址:https://www.cnblogs.com/jizhiqiliao/p/13066924.html