javascript - jQuery autocomplete and locally fetched json data -


i struggling jquery ui autocomplete , reading autocomplete values variable stores data returned json array. javascript looks like:

function populate_branch(){      $.get('/branch/list', {bank_name : $("#select_bank_name").val()}, function(branch_data){         branch_index = branch_data;      },"json"); };  for( var = 0; < branch_index.length; i++ )   branch_autocomplete += "" + "\'" + branch_index[i].branch_code + "\'" + "},";  $("#branch_auto_complete").autocomplete({             source: branch_autocomplete }); 

what happens when try use auto complete textbox console weird, returns this:

//localhost:3000/undefined%7b'label':'301105'%7d,%7b'label':'301205'%7…'label':'639625'%7d,%7b'label':'639845'%7d,%7b'label':'639948'%7d,?term=41 404 (not found)

any help?

this did make work,

var branch_index; var branch_autocomplete, branch_name; var index_branch_code = new array(); function populate_branch(){      $.get('/branch/list', {bank_name : $("#select_bank_name").val()}, function(branch_data){         branch_index = branch_data;         for( var = 0; <  branch_index.length; ++ )         {             index_branch_code[i] = branch_index[i].branch_name + " ("  + branch_index[i].branch_code + ")";         }      },"json"); };  $("#branch_auto_complete").autocomplete({       minlength: 0,       source: branch_code, }); 

i needed push data array , create new variable equal index_branch_code browser sees variable flat file instead of being dynamic.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -