javascript - Autocomplete AJAX request based on input instead of returning all results -


i using autocomplete plugin called fcbkcomplete , works charm. problem , concern is, apparently (that how think) when ever enter char in input result in drop down, result returned json response , response searched display results on drop down.

in other word, following url:

http://this.com/usersapi.do 

the search query like:

select * user_table  

when request gets sent url results , size not small @ all.

what looking way can search chars enter in input field. url this:

http://this.com/usersapi.do?name=? 

so query executed

select * user_table name xxx 

xxx chars have entered far. next char enter y query changes to

select * user_table name xxxy  

and on

this result in lighter json response , less load on servers.

so please me out thanks,

hi can use this.

    $( "#fieldid").autocomplete({          source:          function( request, response ) {               $.ajax({                  url: "test.do",                  data : {"searchtext":request.term}                  context: document.body                  }).done(function() {                      response( $.map( data.dropvalues, function( item ) {                                     var returnobj = new object();                                     returnobj['label'] = item.id + '--' + item.value;                         }                  });          },         minlength: 1,          mustmatch:true,         autoselect :true,         delay:0,         }).data( "autocomplete" )._renderitem = function( ul, item ) {          var html = '<li><a>' + item.label;             html += '</a></li>';         return $(html).data('item.autocomplete', item).appendto( ul );     }; 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -