【问题标题】:jQuery ajax(): can't filter tr append to tbodyjQuery ajax():无法过滤 tr 附加到 tbody
【发布时间】:2013-08-23 13:08:20
【问题描述】:

这里是我的 PHP sn-p ajax resquest 响应 foreach;

$output = '';
   foreach($result->data as $v){
      $output .= '<tr class="s-container" id="box-'.$v->Code.'">';
         $output .='<td>'.$v->Name.'</td>';
      $output .= '</tr>'; //end s-s-contanier
   } 
echo $output;

这里Ajax sn -p 成功函数

.done(function(resultData) {
   var offerData = $(resultData).filter('.s-container');
   $("#offerDispaly tbody").append(offerData);
});

这里用table html来显示tr

<table id="offerDispaly">
<thead>
    <tr>
      <td class="transp"><p><a href="#">Name</a></p></td>
    </tr>
</thead>
<tbody>
    // to append the tr
</tbody>

问题是我无法让 tr 显示数据,如果我将 tr 更改为 div 他工作得很好

感谢您的帮助!

【问题讨论】:

    标签: php jquery ajax


    【解决方案1】:

    使用

    .done(function(resultData) {
         $("#offerDispaly tbody").append(resultData);
    });
    

    【讨论】:

    • 这个只附加数据而不是 tr 所以我喜欢得到我的 tr 并显示
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-20
    • 2011-04-14
    • 2019-06-27
    • 2016-04-04
    • 2018-04-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多