Hi All,
I couldn't be able to figure out the problem in the below case. I have a webmethod and calling the same using jquery ajax call. Below is the code.
[WebMethod(EnableSession = true)]
[ScriptMethod()]
public void SaveSearch(cnt strProp)
{
}
where cnt is the class.
When i calling this using ajax call like.
var strArray = {
cntName : "1",
cntEmail : "2",
cntMsg : "3"
}
$.ajax({
url: '/getproductsservice.asmx/SaveSearch',
method: 'POST',
data: { strProp : strArray},
contentType: 'application/json; charset=utf-8',
success: function (data) {
var showMsg = ''
alert(showMsg);
},
error: function (data) {
alert('Save Search Failed');
}
});
When running this, i got the exception stating that "SaveSearch Service method name is not valid".
But if I replace the parameter with primitive data type like string or int it is working well. Problem is with the object types (list or object etc).
And if I use the primitive type, it is working only if the ajax content type is "content/xml" not working with "content/json". If I use the json type getting another exception of "An attempt was made to call the method \u0027SaveSearch\u0027 using a GET request, which
is not allowed."
Kindly help to resolve this.