javascript - Jquery Autocomplete doesn't work -


i'm trying add autocomplete input box (i'm in asp.net/vb.net project) autocomplete source database. i've created webservice , did ajax call:

<script type="text/javascript">             $(document).ready(function () {                  $('#modelloinput').autocomplete({                      source: function (request, response) {                         $.ajax({                             type: "post",                             contenttype: "application/json; charset=utf-8",                             url: "webservices/autocompletews.asmx/gettuttiimodelli",                             data: "{'prefix':'" + request.term + "'}",                             datatype: "json",                             async: true,                             success: function (data) {                                 response(data.d);                             },                             error: function (result) {                                 //alert("error");                             }                         });                     }                  });             });  </script>  <input type=text  id="modelloinput" /> 

now when run application , write in inputbox got entire list in autocomplete box. can write entire list of elements.

why?

i think there must issue in web-service code,

you can use basic code autocomplete,

$( "input.suggest-user" ).autocomplete({   source: function( request, response ) {      $.ajax({         datatype: "json",         type : 'get',         url: 'yoururl',         success: function(data) {           $('input.suggest-user').removeclass('ui-autocomplete-loading');  // hide loading image          response( $.map( data, function(item) {             // operation on data         }));       },       error: function(data) {           $('input.suggest-user').removeclass('ui-autocomplete-loading');         }     });   },   minlength: 3,   open: function() {    },   close: function() {    },   focus:function(event,ui) {    },   select: function( event, ui ) {    } }); 

or

$("#id").autocomplete( { search: function () {}, source: function (request, response) {     $.ajax(     {         url: ,         datatype: "json",         data:         {             term: request.term,         },         success: function (data)         {             response(data);         }     }); }, minlength: 2, select: function (event, ui) {     var test = ui.item ? ui.item.id : 0;     if (test > 0)     {} } }); 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -