weixin_33721427 2015-08-13 17:20 采纳率: 0%
浏览 12

使用jQuery打印行

I have write a code and getting the values via jQuery and Ajax using the following code, the data comes fine but i could not populate the rows in my table. the looping is not work.

This is my table code in html

<div class="panel-body">
        <table class="table">
            <thead>
            <tr>
                <th>#</th>
                <th>Hospital Details</th>
                <th>Requested Product</th>
                <th>Units</th>
                <th>Patient Details</th>
                <th>Interval</th>
                <th>Requester</th>
            </tr>
            </thead>
            <tbody id="result">

            </tbody>
        </table>
    </div>

This is my ajax script

<script>
    $.get("./../incomingRequestList.php", function(data, status){
        var obj = jQuery.parseJSON(data);
        for($i=0; $i<obj.length; $i++){
            $response +=  "<tr><td>1</td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
        }

        $('#result').html($response);
    });
</script>

How can i overcome this issue. I am unable to find out why its wrong.

  • 写回答

1条回答 默认 最新

  • weixin_33726313 2015-08-13 17:28
    关注

    The correct way to do it is:

    <script>
        $.get("./../incomingRequestList.php", function(data, status){
            var obj = jQuery.parseJSON(data);
            var response = '';
            for(i=0; i<obj.length; i++){
                response +=  "<tr><td>"+obj.number+"</td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
            }
    
            $('#result').html(response);
        });
    </script>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)