Jquery ajax成功调用但是web方法断点未命中

问题描述 投票:0回答:2

我有一个简单的设置。

jQuery的:

$.ajax({
  url: "/MyApp/MyHandler.ashx/MyMethod",
  success: function(result) {
    alert("sucess");
  },
  error: function() {
    alert('Error');
  }
});

和网络方法:

[System.Web.Services.WebMethod]
public static void MyMethod(){
  new AnotherClass(null).AnotherMethod(null, null); 
}

问题是成功警报被调用但是在MyMethod内部没有击中断点。

javascript jquery asp.net ajax webmethod
2个回答
0
投票

我遇到了同样的问题,这是我最终要做的事情:

$.ajax({
   url: _url,
   data: '',
   dataType: 'json',
   contentType: 'application/json',
   type: 'POST',
   success: function(result) {
      alert("sucess");
   },
   error: function() {
      alert('Error');
   }
});

我的第一次尝试遗漏了qazxsw poi,qazxsw poi和qazxsw poi;只有当我用一个空字符串(data)设置dataType时,它最终才能正常工作。真痛十足 - 希望这有助于其他人!


0
投票

在我的情况下,问题出现在RoutingConfig.So中,在RouteConfig中的App_Start文件夹中排序,注释掉以下行

//settings.AutoRedirectMode = RedirectMode.Permanent;

© www.soinside.com 2019 - 2024. All rights reserved.