jQuery ajax仿Google自动提示SearchSuggess功能示例(2)

ALTER PROCEDURE [dbo].[suggest_search] @kw VARCHAR(100) ,@cityid int as begin SELECT TOP 10 * FROM dbo.SearchIndex WHERE cityid=@cityid and keyword LIKE '' + @kw + '%' UNION ALL SELECT TOP 10 * FROM dbo.SearchIndex WHERE cityid= @cityid and pinyin LIKE '' + @kw + '%' ORDER BY searchtimes DESC END

--一定要建组合索引……

var result = list.OrderByDescending(t => t.searchtimes).Select(t => t.keyword.Replace("'", "")).Take(10); string json = JsonConvert.SerializeObject(result, Formatting.Indented); string renderJSON = "KISSY.Suggest.callback({'result':" + json.Replace("\"", "\'") + "})";

更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jquery中Ajax用法总结》、《jQuery扩展技巧总结》、《jQuery常用插件及用法总结》、《jQuery常见经典特效汇总》及《jquery选择器用法总结

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/69aed5d39c0270c2759ac4076cc575a6.html