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>
    
    评论

报告相同问题?

悬赏问题

  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加