Unknown web method using ajax / jquery
ERROR: unknown web method DoIt Parameter name: methodName
I am trying to pass a date to a DB Query function supported by VB.NET, but I am having problems with the website.
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 file.aspx.vb
:
(at the end of the file)
<System.Web.Services.WebMethod()> _
Public Function DoIt(ByVal param As String) As String
UpdateDB(param) 'function is above
End Function
I'm just not entirely sure what is going wrong or what it means; /
+3
source to share
2 answers
Something worth checking out is making sure your database is set up to receive a datetime datatype.
Also try in your web service statement:
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
<WebMethod()> _
Public Function DoIt(ByVal param As String) As String
UpdateDB(param) 'function is above
End Function
Ref: webservice - unknown method method method parameter name
+1
source to share
Check this answer . Perhaps you need to declare the function asShared
<System.Web.Services.WebMethod()> _
Public Shared Function DoIt(ByVal param As String) As String
UpdateDB(param) 'function is above
End Function
+3
source to share