有没有办法将ajax(我正在使用Jquery)与asp.net webforms一起使用,而不必运行页面生命周期?
最佳答案
如果您使用 jQuery,正如您提到的,您可以 use jQuery to call Page Methods directly ,而不会产生 MicrosoftAjax.js 及其生成的用于启用 PageMethods.MethodName()
语法的服务代理的开销。
给定 PageName.aspx
中名为 MethodName
的静态 [WebMethod]
修饰方法,这是如何调用它的示例在客户端:
$.ajax({
type: "POST",
url: "PageName.aspx/MethodName",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
// Do something interesting with msg.d here.
}
});
关于jquery - 如何在 ASP.NET WebForms 中使用 Ajax,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5331986/