Estou criando um webmetod que fara o autocomplete de alguns campos da minha tela, porem estou recebendo erro 500
<System.Web.Services.WebMethod>
<System.Web.Script.Services.ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=False)>
Public Function AutoComplete(ByVal prefixText As String) As String
Dim resposta As string = "funciona"
Return Newtonsoft.Json.JsonConvert.SerializeObject(resposta)
End Function
como podem ver é bem simples apenas para ver se retorna a mensagem do servidor
Meu javascript
function buscaPorParametro(campo) {
var valorDigitado = $("input[name='" + campo +"']")
console.log(txtBox.val())
$.ajax({
data: JSON.stringify("{ prefixText: '" + valorDigitado.val() + "' }"),
dataType: "json",
url: url,
type: "POST",
contentType: "application/json; charset=utf-8",
success: OnSuccess,
error: onError
});
}
function OnSuccess(data) {
}
function onError(err) {
console.log(err);
$('#LoadingPanel').css('display', 'none');
}
erro retornado do servidor
"{"Message":"Cannot convert object of type \u0027System.String\u0027 to type \u0027System.Collections.Generic.IDictionary`2[System.String,System.Object]\u0027","StackTrace":" at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object\u0026 convertedObject)\r\n at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object\u0026 convertedObject)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)\r\n at System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest(HttpContext context, JavaScriptSerializer serializer)\r\n at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}"
alguém saberia me dizer onde estou errando?
Obrigado