Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery, Prepend data strips html tags, and output gets messed up
    primarykey
    data
    text
    <p>I have below code to retrieve some text from a php document:</p> <pre><code>$.get("server/test.php", function(data){ $('#thumbdest').prepend(data); // $('#thumbdest').html(data); }); </code></pre> <p>The commented line returns everything as expected, but the <code>prepend</code> data does not. It seems to strip HTML tags when inserted. I can't use the commented line because I have to insert multiple items after each other. <code>$('#thumbdest').html(data);</code> replaces everything in the <code>thumbdest</code> div as expected.</p> <p>Below is the HTML I should get when using <code>prepend</code></p> <pre><code>&lt;tr&gt; &lt;td&gt; &lt;a href="#modal" class="thumbnail tableimg" role="button" class="btn" data-toggle="modal"&gt; &lt;img src="assets/img/huvudbilder/thumbs/img.png" class="tableimg" alt=""&gt; &lt;/a&gt; &lt;/td&gt; &lt;td&gt;Test1&lt;/td&gt; &lt;td&gt;Test2&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>This is what I actually get from using <code>prepend</code></p> <pre><code>&lt;a href="#modal" class="thumbnail tableimg" role="button" class="btn" data-toggle="modal"&gt; &lt;img src="assets/img/huvudbilder/thumbs/img.png" class="tableimg" alt=""&gt; &lt;/a&gt; Test1 Test2 </code></pre> <p>Which in turn screws up the whole table. All the table elements disappear, why is that?</p> <p>EDIT: When testing <code>alert(data)</code> after the prepend I get below:</p> <pre><code>&lt;tr&gt; &lt;td&gt; &lt;a href="#editImage_1222866094" class="thumbnail tableimg" role="button" class="btn" data-toggle="modal"&gt; &lt;img src="assets/img/huvudbilder/thumbs/favicon32.png" class="tableimg" alt=""&gt; &lt;/a&gt; &lt;/td&gt; &lt;td&gt;Test1&lt;/td&gt; &lt;td&gt;Test2&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>Structure of the <code>#thumbdest</code>:</p> <pre><code> &lt;table class="table table-hover"&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;&lt;/th&gt; &lt;th&gt;Namn&lt;/th&gt; &lt;th&gt;Tid&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody id="thumbdest"&gt;&lt;/tbody&gt; &lt;tbody&gt; &lt;?php getImageList($conn); ?&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload