I am using twitter bootstrap 2.0.4. I want to populate a dropdown with ajax. The source property of the typeahead plugin requires that the source value be either an array or a function. I tried changing the value of the array after the ajax request, but it only displays the results of the first request.
<form class="navbar-search"> <input type="text" id="searchSong" class="typeahead" placeholder="Search"> </form> $('.typeahead').keyup(function(){ var list; var q = $('.typeahead').val(); if(!q){ return; } $.ajax({ type: "GET", url: "/WebApplication1/Playlist/search?query="+q, success: function(data){ list = data.split(','); alert(list); $('.typeahead').typeahead({ source: list }) } });
the warning window shows the data downloaded from ajax, but the previous values ββare still displayed in the drop-down list
source share