How to print JSON rest api data on HTML list format by using typedata

158 Views Asked by At

I am using typescript for showing live search my JSON rest API data is showing but I want to show the data on list format but using for loop is will show only one data Here is my code :

<div class="row">
<div class="col-md-12 text-center">
    <br/>
    <h1>Search Dynamic Autocomplete using Bootstrap Typeahead JS</h1>   
        <input class="typeahead form-control" style="margin:0px auto;width:300px;" type="text">
</div>

This is my HTML file where I am show the live search data

enter $(document).ready(function(){
$('input.typeahead').typeahead({
  source:  function (query, process) {
    return $.post('ip.php/test/search', { query: query }, function (data) {
        var res1 = [];
        res1 = JSON.stringify(data);
        for (var k=0;k<res1.length;k++) {
        var question = data[k].questionText ;    
        $(".row").("" +data[k].questionText);       
      }    
   });
 }

}); });

This is my typehead function in this I want to show all search data but it will showing the single result

0

There are 0 best solutions below