XML响应jQuery的动态表



我正在尝试使用来自XML响应的数据创建表行。

这是我的成功函数:

 success: function(response) {
            $('id', response).each(function() {
                 const row = $('<tr>');
                 row.append($('<td>').html($(this).find('name').text()));
                 row.append($('<td>').html($(this).find('result').text()));
                 row.append($('<td>').html($(this).find('date').text()));
                 $('#result-list').append(row);

             });

这是我的html:

    <table id="result-list" class="table table-striped" style="margin-top:15px;">
 <thead>
  <tr>
     <th scope="col">name</th>
     <th scope="col">result</th>
     <th scope="col">date</th>
   </tr>
 </thead>
 <tbody>
</tbody>
</table>

问题在于它将一行中的所有变量附加。例如,它在同一行中附加所有结果变量。我想为每个名称,结果和日期字段创建一个新行。

名字,结果,第1行。第二个名称,结果,第2行等日期等等..

,所以这与表创建无关。问题在于,在XML响应中,我将所有ID都包裹在ID中(ID标签的大写版)。我不知道jQuery解析字符串对案例不敏感。

so $ .. parsexml(响应),而不是响应解决了我的问题:我一直在使用jQuery来解析XML,但没有维护大写。是否缺少一个标志?

最新更新