0

我在我的 asmx 文件中定义了一个 web 方法,如下所示

  <WebMethod(EnableSession:=True)> _
    Public Function HelloWorld(ByVal theResp As String) As String
        Return "HelloWorl"+ theResp
    End Function

当我使用 ajax 向它发送测试并取回它时,它工作得非常好

$.ajax({
    type:'POST',
    url: "/GettingData.asmx/HelloWorld",        
    dataType:"text",       
    data: "It's me",
    async: true,
    success: function (data) {           
        console.log(data);
    },
    error: function () {
        console.log("there is a problemsending the XML");
    }
});

我收到 500 内部服务器错误,经过仔细检查,我看到响应文本说

responseText: "System.InvalidOperationException: Missing parameter: paramType.↵ at    
System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection  
collection)↵   
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()↵

我发现了一个可能会有所启发的小线程,但它对我没有帮助。http://forums.asp.net/t/1752866.aspx/1这是因为我不确定我的客户端代码(在 javascript 中)将如何调用 theResp。

4

1 回答 1

0

这应该有效:

data: { theResp: "It's me" },
于 2013-08-08T21:44:07.133 回答