我正在尝试文本框的自动完成功能,其中我向 webmethod 发送 get 请求,该 webmethod 返回完整的页面内容而不是实际数据,如下所示。
我正在使用以下 C# 代码,而我使用 Post 请求的所有其他方法都工作正常
[WebMethod]
[ScriptMethod(UseHttpGet=true,ResponseFormat=ResponseFormat.Json)]
public static string GetListOfUsers()
{
return "{'0701414001','0701414002'}";
}
最佳答案
我认为问题出在您的参数中:您正在调用 Email.aspx/GetListOfUusers?query=lkkjlk
但您的 public static string GetListOfUsers()
不包含参数名称。
尝试更改为:
public static string GetListOfUsers(string query)
{
...
}
我还会尝试删除此内容:ResponseFormat=ResponseFormat.Json
并查看它是否会改变任何内容。
关于jquery - ASP.net WebMethod 返回完整的页面内容而不是 JSON 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10776113/