ajax模糊查询

来源:互联网 发布:淘宝联盟淘宝身份认证 编辑:程序博客网 时间:2024/04/29 11:43
<script type="text/javascript">          $(function() {              $('#level1').keyup(function() {                  var n=$(this).val();                  if(n!=''){                      $.ajax({                          type: "post",                          url: "userRoleInfo/selectListAdmin",                          data:{n:n},                          dataType: "json",                          success: function(data) {                              $("#tb").empty();                              var str = "";                              $.each(data,function(commendIndex,comment){                                  if(comment['username'].indexOf(n)>=0){                                      str +='<tr><th>'+comment['username']+'</th><th>'+comment['sex']+'</th><th>'+comment['birthday']+'</th><th>'+comment['phone']+'</th><th>'+comment['email']+'</th><th>'+comment['location']+'</th><th>'+comment['roleName']+'</th><th>'+comment['roleStatus']+'</th></tr>';                                  }                              });                              $("#tb").append(str);                          }                      });                   }else{                      $("#tb").empty()                  }              });          });  </script>

原创粉丝点击