jquery - Autocomplete Textbox from Active Directory usind LDAP Users in php -


i trying autocomplete field picks names of users ldap. codes follows :

index.php

$(document).ready(function() {    $("#search-box").keyup(function() {      $.ajax({        type: "post",        url: "readcountry.php",        data: 'keyword=' + $(this).val(),        beforesend: function() {          $("#search-box").css("background", "#fff url(loadericon.gif) no-repeat 165px");        },        success: function(data) {          $("#suggesstion-box").show();          $("#suggesstion-box").html(data);          $("#search-box").css("background", "#fff");        }      });    });  });    function selectcountry(val) {    $("#search-box").val(val);    $("#suggesstion-box").hide();  }
body {    width: 610px;  }  .frmsearch {    border: 1px solid #f0f0f0;    background-color: #c8eefd;    margin: 2px 0px;    padding: 40px;  }  #country-list {    float: left;    list-style: none;    margin: 0;    padding: 0;    width: 190px;  }  #country-list li {    padding: 10px;    background: #fafafa;    border-bottom: #f0f0f0 1px solid;  }  #country-list li:hover {    background: #f0f0f0;  }  #search-box {    padding: 10px;    border: #f0f0f0 1px solid;  }
<html>    <head>    <title>jquery ajax autocomplete - country example</title>      <head>        <body>        <div class="frmsearch">          <input type="text" id="search-box" placeholder="country name" />          <div id="suggesstion-box"></div>        </div>      </body>    </html>

readcountry.php

                <?php              if(!empty($_post["keyword"])) {              $name=$_post["keyword"];             $username="********";             $password="********";             $lc = ldap_connect("********") or             die("couldn't connect ad!");             ldap_set_option($lc, ldap_opt_protocol_version, 3);             ldap_bind($lc,$username,$password);             $base = "ou=********,dc=********,dc=********";             $filt = "(&(&(&(objectcategory=person)(objectclass=user)(name=$name*))))";             $sr = @ldap_search($lc, $base, $filt);             $info = ldap_get_entries($lc, $sr);             ($i = 0; $i < $info["count"]; $i++) {             $info[$i]["cn"][0] ;             }             if ($i == 0) {             echo "no matches found!";             }              if(!empty($info[$i]["cn"][0])) {             ?>             <ul id="country-list">             <?php             foreach($info[$i]["cn"][0] $country) {             ?>             <li onclick="selectcountry('<?php echo $country ?>');"><?php echo   $country ?></li>             <?php } ?>             </ul>             <?php } } ?> 

what have :

this isn't returning names ldap nor there error dispalyed me fix it.

what need :

enter image description here

when typed, names starting 'a' should shown in dropdown.

appreciate :) in advance! :)

$('#search').keyup(function () {     var data = this.value.split(" ");     var rows = $("#table tbody tr").hide();     if(this.value ===""){         rows.show();         return;     }         rows.hide();         rows.filter(function(i,v){             var t = $(this);             (var d = 0; d < data.length; d++) {                 if (t.is(":contains('" + data[d] + "')")) {                     return true;                 }             }                     return false;         }).show(); }); 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -