有人可以举例说明使用网络服务将键值对传递给jQuery自动完成列表。
救援坦克。
$('#txtBox1').autocomplete("Autocomplete.asmx/GetKeyValu",
{ dataType: "xml", datakey: "string", max: 10, minChars: 0 });
[WebMethod]
public Dictionary<string,string> GetKeyValu(string q, int limit)
{
Dictionary<string, string> dict = new Dictionary<string, string>();
dict.Add("key1", "valu1");
return dict;
}
答案 0 :(得分:0)
大多数浏览器无法直接调用SOAP Web服务。将WebMethod更改为页面或IHttpHandler呈现Javascript。
void IHttpHander.ProcessRequest( HttpContext context )
{
Dictionary<string, string> dict = new Dictionary<string, string>();
dict.Add("key1", "valu1");
foreach (var key in dict) {
context.Response.Write( key );
context.Response.Write( "|" );
context.Response.Write( dict[key] );
context.Response.Write( "\n" );
}
}