dongmi1663 2018-08-10 07:00
浏览 65

如何使用typedata在HTML列表格式上打印JSON rest api数据

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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作