ajax分页效果、分类联动、搜索功能
2017-07-31 22:57
369 查看
一、使用smarty+ajax+php实现无刷新分页效果
效果图
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>jsonp</title> 6 <link rel="stylesheet" href="../css/reset.css"> 7 <style> 8 .con{ 9 width:400px; 10 margin:50px auto; 11 font-size: 0; 12 } 13 .con input{ 14 width:270px; 15 height:6px; 16 padding:15px; 17 } 18 .con button{ 19 width:96px; 20 height:40px; 21 line-height:40px; 22 border:none; 23 font-size:14px; 24 padding: 0; 25 background:#3385ff; 26 border-bottom:1px solid #2d78f4; 27 color:#fff; 28 } 29 .search_content{ 30 font-size:14px; 31 border:1px solid #ccc; 32 margin-top:-1px; 33 display: none; 34 } 35 .search_content li{ 36 padding: 2px 15px; 37 margin-top:5px; 38 } 39 .search_content li:nth-child(1){ 40 margin-top: 0; 41 } 42 .search_content li:hover{ 43 background:#cccccc; 44 cursor: pointer; 45 } 46 </style> 47 <script src="../js/jquery-1.12.4.min.js"></script> 48 <script> 49 $(function(){ 50 $("#search").keyup(function(){ 51 var keyword = $(this).val(); 52 //使用$.trim()方法去除字符串两端的空白字符 53 if($.trim(keyword).length == 0){ 54 return false; 55 } 56 $.ajax({ 57 url:"https://sug.so.360.cn/suggest?", 58 type:"get", 59 dataType:"jsonp", 60 data:{word:keyword} 61 }).done(function(data){ 62 if(data.p == true){ 63 var str = ""; 64 if(data.s.length>0){ 65 for(var i=0;i<data.s.length;i++){ 66 str +="<li>"+data.s[i]+"</li>"; 67 } 68 $(".search_content").html(str); 69 $(".search_content").show(); 70 }else{ 71 $(".search_content").html(str); 72 $(".search_content").hide(); 73 } 74 75 } 76 console.log(data) 77 }).fail(function(error){ 78 console.log("error"); 79 }) 80 }); 81 $(".search_content").delegate("li","click",function(){ 82 $("#search").val($(this).html()); 83 $(this).parent().hide(); 84 }) 85 }) 86 </script> 87 </head> 88 <body> 89 <div class="con"> 90 <input id="search" type="text" placeholder="请输入内容"> 91 <button>搜索</button> 92 <ul class="search_content"></ul> 93 </div> 94 </body> 95 </html>
搜索功能代码
相关文章推荐
- (经典)分页组件,3种不同样式的分页效果,数字,按钮,标题搜索等功能
- Yii框架结合sphinx,Ajax实现搜索分页功能示例
- 原生javascript实现分页效果+搜索功能
- Ajax实现搜索功能的分页
- 1.MVC框架复习 2.Ajax加强 3.搜索建议 4,三级联动 5、刷新分页 6、Ajax局部动态更新数据
- Yii框架结合sphinx,Ajax实现搜索分页功能示例
- ajax用三层写的无刷新效果的分页功能
- (经典)分页组件,3种不同样式的分页效果,数字,按钮,标题搜索等功能
- jquery Json Ajax搜索与分页效果代码
- PHP无级分类续及搜索功能,分组分页
- 1.MVC框架复习 2.Ajax加强 3.搜索建议 4,三级联动 5、刷新分页 6、Ajax局部动态更新数据
- Android 仿联系人列表 实现ListView的A-Z字母排序和过滤搜索功能,并挤压效果
- Ajax搜索提示功能
- Extjs + java + ibatis 具有搜索功能的分页组件
- Bootstrap Paginator分页插件与ajax相结合实现动态无刷新分页效果
- yii2框架 自带搜索 ,分页(功能强大)CURD
- ajax实现联动效果全攻略(极力推荐)
- Ajax实现无刷新分页效果
- jQuery 结合AJAX实现添加、删除分类等功能【原创】
- jsp单页面数据库查询模板:支持分页、排序、简单搜索、设置每页显示页数功能