Here is my ajax request:
$("#<% =txtDiagnosisData.ClientID %>").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
url: 'EMR.aspx/SearchDiagnosis',
contentType: "application/json;charset=utf-8",
dataType: "json",
success: function (data) {
// response(data.d);
alert("success");
},
error: function (result) {
alert("error");
}
});
}
});
Here is my function:
[WebMethod]
public static List<string> SearchDiagnosis()
{
return new DataAccess().GetDiagnosis();
}
My method is not called from ajax, it always goes to the error part How to solve this?
There could be an issue that you might be using
Sessionvariables inside you web method directly or indirectly.Somewhere in the function
DataAccess().GetDiagnosis();In that case use attribute like
[WebMethod(enableSession: true)]in stead of[WebMethod]Also try to get the error by implementing error properly like belowRef : jQuery ajax error function and see what error exactly you are getting.