当我点击图片时,我的asmx webservice正在调试,但我的jquery成功函数不起作用。
这是我的jquery函数
if (e.key === 'toes') {
debugger;
$.ajax({
url: "SympsService.asmx/GetSymptoms",
data:{ organ_name: "toes" },
method: "post",
dataType: "json",
success: function (data) {
debugger;
alert("ok");
error: function (error) {
console.log(error);
}
})
}
这是我的asmx webservice代码
[WebMethod]
public string GetSymptoms(string organ_name)
{
List<symps> listSymptoms = new List<symps>();
string CS = ConfigurationManager.ConnectionStrings["EhealthConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
SqlCommand cmd = new SqlCommand("sendSymptoms", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter parameter = new SqlParameter();
parameter.ParameterName = "@organ";
parameter.Value = organ_name;
cmd.Parameters.Add(parameter);
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
symps symp = new symps();
symp.Sympt = rdr["SymptomsName"].ToString();
listSymptoms.Add(symp);
}
string serializedList = JsonConvert.SerializeObject(listSymptoms);
return serializedList;
//JavaScriptSerializer js = new JavaScriptSerializer();
//Context.Response.Write(js.Serialize(listSymptoms));
}
}
我无法理解代码中的问题。请帮助我。 提前致谢。