0

I have a web method defined in my asmx file like this

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

and it works perfectly fine when I use ajax to send it a test and get it back

$.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");
    }
});

I am getting a 500 internal server error and upon closer inspection I see that the response text says that

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

I found a small thread that might shed some light, but it is not helping me. http://forums.asp.net/t/1752866.aspx/1 this is becuase I am not sure how my code from the client side (in javascript) will call theResp.

1 Answer 1

0

This should work:

data: { theResp: "It's me" },
6
  • Will he need to change his dataType to json? Aug 8, 2013 at 21:49
  • I believe dataType is the return type. The $.ajax docs say the data property can be a plain object.
    – Jason P
    Aug 8, 2013 at 21:53
  • I though that if you send an object type it get converted into a query string, because of the processData default is true. So I though that passing in a string would be fine but I guess I have to wrap it in an object so it can be converted to a string?
    – Jack Thor
    Aug 8, 2013 at 21:59
  • I assume that if you just send a string, it doesn't know what parameter to match that up with on the server side.
    – Jason P
    Aug 8, 2013 at 22:08
  • oh ok, so if I send the object I have to make sure the object has the same name.
    – Jack Thor
    Aug 8, 2013 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.