【问题标题】:jquery Ajax post forbiddenjQuery Ajax 帖子被禁止
【发布时间】:2016-02-24 09:20:47
【问题描述】:

我对 jquery 的一个简单的 ajax 帖子有疑问:

$.ajax({
  type: 'POST',
  url: "ucUploadDownloadCommand.ascx/UploadXLSFile",
  data: "{}",
  dataType: 'json',
  contentType: "application/json; charset=utf-8",
  success: function (response) {
       $(".im").css('visibility', 'hidden');
  },
  error: function(xhr, textStatus, error){
          alert(xhr.statusText);
          alert(textStatus);
          alert(error);
  }

在代码后面(文件ucUploadDownloadCommand.ascx.vb):

<System.Web.Services.WebMethod()> _
    Public Shared Sub UploadXLSFile()
        Dim a As New StringBuilder()
        ...
    End Sub

但它出错了

“禁止”错误(没有“未找到”一个)

。我怎么解决这个问题?

提前致谢。

【问题讨论】:

    标签: jquery asp.net ajax post


    【解决方案1】:

    无法在用户控件中调用 Web 方法。您需要将方法定义直接移动到页面。据我所知,网络方法需要是静态的才能工作。

    【讨论】:

      猜你喜欢
      • 2021-10-16
      • 1970-01-01
      • 2011-11-25
      • 2019-07-16
      • 2011-12-21
      • 1970-01-01
      • 1970-01-01
      • 2018-04-10
      • 2011-06-01
      相关资源
      最近更新 更多