页面:
复制代码 代码如下:
测试
后台: 
复制代码 代码如下:
using system; 
using system.web; 
public class getallwords : ihttphandler 
{ 
public void processrequest(httpcontext context) 
{ 
if (context.request.querystring[term] != null && context.request.querystring[term] != ) 
{ 
context.response.clear(); 
context.response.charset = utf-8; 
context.response.buffer = true; 
context.response.contentencoding = system.text.encoding.utf8; 
context.response.contenttype = text/plain; 
context.response.write(getlikeusername(context.request.querystring[term])); 
context.response.flush(); 
context.response.close(); 
context.response.end(); 
} 
} 
/// 
/// 拼接json 
/// 
/// 关键词 
/// 
private string getlikeusername(string key) 
{ 
jhg.bll.web_wordmanager wordmanager = new jhg.bll.web_wordmanager(); 
//搜索,返回10个关键词 
string[] listword = wordmanager.getsearchword(key, 10); 
system.text.stringbuilder sbstr = new system.text.stringbuilder([); 
int ct = listword.length; 
for (int i = 0; i { 
sbstr.append(\ + listword[i] + \); 
if (i == ct - 1) 
sbstr.append(]); 
else 
sbstr.append(,); 
} 
return sbstr.tostring(); 
} 
public bool isreusable 
{ 
get 
{ 
return false; 
} 
} 
}
注: 
文件:jquery.ui.autocomplete.css 
.ui-autocomplete { position: absolute; cursor: default; } 
去掉: position: absolute; 
效果图:
   
 
   