Jquery WebMethod未启动
问题: 激发showCurrentTime()时,永远不会调用WebMethod GetCurrentTime() 成功功能将触发并显示空警报Jquery WebMethod未启动,jquery,asp.net,webforms,Jquery,Asp.net,Webforms,问题: 激发showCurrentTime()时,永远不会调用WebMethod GetCurrentTime() 成功功能将触发并显示空警报 页面上有一个脚本管理器 JQuery是嵌入式的 尝试 url:''。同样的问题 尝试启用PageMethods,然后调用WebMethod,如下所示,并得到相同的问题 PageMethods.GetCurrentTime(onSuccess, onError); function onSuccess(resp) { al
页面上有一个脚本管理器 JQuery是嵌入式的 尝试 url:''。同样的问题 尝试启用PageMethods,然后调用WebMethod,如下所示,并得到相同的问题
PageMethods.GetCurrentTime(onSuccess, onError);
function onSuccess(resp) { alert(resp.d); }
function onError(resp) { alert(resp.d); }
谢谢你的帮助。谢谢
function showCurrentTime() {
$.ajax({
type: "POST",
url: "WebMethodTest2.aspx/GetCurrentTime",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) { alert(response.d); },
failure: function (response) { alert(response.d); }
});
}
如果其他任何人在没有意识到Asp.NET.FriendlyURL与此问题相关的情况下遇到此问题 在RouteConfig.cs中注释掉
//settings.AutoRedirectMode = RedirectMode.Permanent;
在这里找到了答案:
//settings.AutoRedirectMode = RedirectMode.Permanent;