Autocomplete textbox with multiple data from database in CodeIgniter using Jquery

Autocomplete textbox with multiple data from database in CodeIgniter using Jquery

  
I want some help from anyone to do this Autocomplete textbox. Right now the data is coming from the database well but I want to restrict displaying the duplicate data.

CODE: 

$(function() { function split( val ) { return val.split( /,\s*/ ); } function extractLast( term ) { return split( term ).pop(); } function log( message ) { $( "<input name='skill'>" ).text( message ).prependTo( "#log" ); $( "#log" ).scrollTop( 0 ); } $( "#birds" ).bind( "keydown", function( event ) { if ( event.keyCode === $.ui.keyCode.TAB && $( this ).autocomplete( "instance" ).menu.active ) { event.preventDefault(); } }) .autocomplete({ minLength: 1, source: function( request, response ) { $.getJSON("http://localhost:8888/auto/index.php/birds/get_birds", { term : extractLast( request.term )}, response); }, focus: function() { return false; }, select: function( event, ui ) { var terms = split( this.value ); if(terms.length <= 3) { terms.pop(); terms.push( ui.item.label); log(ui.item.value); terms.push( "" ); this.value = terms.join( ", " ); return false; }else{ var last = terms.pop(); $(this).val(this.value.substr(0, this.value.length - last.length - 2)); $(this).effect("highlight", {}, 1000); $(this).attr("style","border: solid 1px red;"); return false; } }, change: function (event, ui) { if (!ui.item) { $(this).val(''); } } }); });