问题:
当showCurrentTime()被触发时,WebMethod GetCurrentTime()永远不会被调用。
成功的功能是触发和显示一个空警报。
页面上有一个脚本管理器。
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); }
});
}
[WebMethod]
public static string GetCurrentTime()
{
return DateTime.Now.ToString();
}发布于 2014-05-29 02:54:51
如果其他人在没有意识到的情况下遇到这种情况,Asp.NET.FriendlyURLs就会与问题相关。
在RouteConfig.cs中注释掉
//settings.AutoRedirectMode = RedirectMode.Permanent;https://stackoverflow.com/questions/23923794
复制相似问题