I have created an ajax call and am trying to send an object as an argument to the server but I am getting the following error:
Invalid web service call, missing value for parameter: 'itemTypes'
I have checked the itemTypes variable in javascript and it contains the expected values:
sessionStorage.itemTypeUid = "18"
sessionStorage.itemTypeName = "TABLE_NAME"
args = {CurId: 18, BaseTableName: "TABLE_NAME"}
javascript:
var itemTypes = {
CurId: parseInt(sessionStorage.itemTypeUid),
BaseTableName: sessionStorage.itemTypeName
};
aj("DeleteItem", itemTypes);
Ajax:
function aj(funcName, args) {
retval = $.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: 'ItemEdit.asmx/' + funcName,
data: JSON.stringify(args),
dataType: "json",
error: function (a, b, c) {
var errors = a + b + c
}
});
}
VB:
<WebMethod()>
Public Sub DeleteItem(itemTypes As Object)
Dim CurId = ""
Dim BaseTableName = ""
actions.DeleteItem(CurId, BaseTableName)
End Sub
You can update your web method like:
<WebMethod()>
Public Sub DeleteItem(CurId As Integer, BaseTableName As String)
actions.DeleteItem(CurId, BaseTableName)
End Sub
Please make sure parameter name here is exactly the same as the values passed in the ajax call. Even if the name is the same but the casing is different, then you might get errors. So, please double-check the variable names first. Also, remove
Dim CurId = ""
Dim BaseTableName = ""
from the method, so that there are no name conflicts.