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

    报告相同问题?

    悬赏问题

    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示
    • ¥15 求三国群英传pl国战时间的修改方法
    • ¥15 matlab代码代写,需写出详细代码,代价私
    • ¥15 ROS系统搭建请教(跨境电商用途)
    • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。
    • ¥20 CST怎么把天线放在座椅环境中并仿真
    • ¥15 任务A:大数据平台搭建(容器环境)怎么做呢?