PHPドキュメントからテキストを取得するための以下のコードがあります:
$.get("server/test.php", function(data){
$('#thumbdest').prepend(data);
// $('#thumbdest').html(data);
});
コメント行はすべてを期待どおりに返しますが、prepend
データは返しません。挿入するとHTMLタグが削除されるようです。複数の項目を続けて挿入する必要があるため、コメント行を使用できません。期待どおりにdiv$('#thumbdest').html(data);
内のすべてを置き換えます。thumbdest
以下は、使用するときに取得する必要があるHTMLですprepend
<tr>
<td>
<a href="#modal" class="thumbnail tableimg" role="button" class="btn" data-toggle="modal">
<img src="assets/img/huvudbilder/thumbs/img.png" class="tableimg" alt="">
</a>
</td>
<td>Test1</td>
<td>Test2</td>
</tr>
これは私が実際に使用することから得られるものですprepend
<a href="#modal" class="thumbnail tableimg" role="button" class="btn" data-toggle="modal">
<img src="assets/img/huvudbilder/thumbs/img.png" class="tableimg" alt="">
</a>
Test1
Test2
これにより、テーブル全体が台無しになります。すべてのテーブル要素が消えます、それはなぜですか?
編集:alert(data)
プリペンドの後にテストするとき、私は以下を取得します:
<tr>
<td>
<a href="#editImage_1222866094" class="thumbnail tableimg" role="button" class="btn" data-toggle="modal">
<img src="assets/img/huvudbilder/thumbs/favicon32.png" class="tableimg" alt="">
</a>
</td>
<td>Test1</td>
<td>Test2</td>
</tr>
の構造#thumbdest
:
<table class="table table-hover">
<p> </p>
<thead>
<tr>
<th></th>
<th>Namn</th>
<th>Tid</th>
</tr>
</thead>
<tbody id="thumbdest"></tbody>
<tbody>
<?php getImageList($conn); ?>
</tbody>
</table>