【问题标题】:unknown web method using ajax/jquery使用 ajax/jquery 的未知网络方法
【发布时间】:2012-04-16 11:59:05
【问题描述】:
ERROR: unknown web method DoIt Parameter name: methodName

我正在尝试将日期传递到由 VB.NET 支持的 DB Query 函数中,但在网页端遇到问题。

var dat = $("#Date").val(); //textbox with a date    

$.ajax({
                    type: "POST",
                    url: "file.aspx/DoIt",
                    cache: false,
                    contentType: "application/json; charset=utf-8",
                    data: {param:dat},
                    dataType: "json",
                    success: function (data, status) {
                        var response = $.parseJSON(data.d);
                        alert(response.message);
                        alert(status);
                    },
                    error: function (xmlRequest) {
                        alert(xmlRequest.status + ' \n\r ' + xmlRequest.statusText + '\n\r' + xmlRequest.responseText);
                    }
                });     

file.aspx.vb 文件:

(在文件末尾)

<System.Web.Services.WebMethod()> _
Public Function DoIt(ByVal param As String) As String
    UpdateDB(param) 'function is above
End Function

我只是不完全确定出了什么问题或这意味着什么;/

【问题讨论】:

  • 你能告诉我们更多关于你在哪里看到错误信息以及它到底说了什么吗?
  • 真的只是一个 500 错误,“未知的 web 方法 DoIt 参数名称:methodName”
  • ...您在 javascript ajax 响应中遇到了该错误?

标签: asp.net ajax vb.net jquery


【解决方案1】:

可能值得一试的是确保您的数据库设置为接收日期时间数据类型。

还可以在您的网络服务声明中尝试:

<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
<WebMethod()> _
Public Function DoIt(ByVal param As String) As String
    UpdateDB(param) 'function is above
End Function

参考:webservice - unknown web method parameter name methodname

【讨论】:

    【解决方案2】:

    查看this answer。您可能需要将函数声明为Shared

    <System.Web.Services.WebMethod()> _
    Public Shared Function DoIt(ByVal param As String) As String
        UpdateDB(param) 'function is above
    End Function
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-17
      • 1970-01-01
      • 1970-01-01
      • 2014-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多