Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8828685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:39:49+00:00 2026-06-14T07:39:49+00:00

I have below code to retrieve some text from a php document: $.get(server/test.php, function(data){

  • 0

I have below code to retrieve some text from a php document:

$.get("server/test.php", function(data){
    $('#thumbdest').prepend(data);
    // $('#thumbdest').html(data);
});

The commented line returns everything as expected, but the prepend 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. $('#thumbdest').html(data); replaces everything in the thumbdest div as expected.

Below is the HTML I should get when using 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>

This is what I actually get from using 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

Which in turn screws up the whole table. All the table elements disappear, why is that?

EDIT:
When testing alert(data) after the prepend I get below:

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

Structure of the #thumbdest:

        <table class="table table-hover">
          <p>&nbsp;</p>
            <thead>
                <tr>
                    <th></th>
                    <th>Namn</th>
                    <th>Tid</th>
                </tr>
            </thead>
            <tbody id="thumbdest"></tbody>
            <tbody>
                <?php getImageList($conn); ?>
            </tbody>
        </table>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:39:51+00:00Added an answer on June 14, 2026 at 7:39 am
    <!DOCTYPE HTML>
    <html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <title>Script Test</title>
        <script src="jquery.min.js"></script>
        <script>
    
        // example
    
            $(function() {
                $('.button').click(function(e) {
                    e.preventDefault();
                    var $mytext = "<a href=\"#\">Test</a>";
                        $("#key").prepend($mytext);
    
                    });
            });
    
        </script>
    </head>
    <body>
    
        <a href="" class="button">Test</a>
        <div id="key"></div>
    
    </body>
    </html>
    

    Here, prepend() is working as it is supposed to, not to strip tags.

    What you need to do is to place the <tbody> inside the <div id="thumbdest"> and then change your following script line from $('#thumbdest').prepend(data); to $('#thumbdest tbody').prepend(data);

    Source: http://forum.jquery.com/topic/prepend-stripping-out-html-table-tags

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the code as per below. This retrieves some data to use for
I have some code that retrieves a scripted svg image from a server via
I have below code in html. <li class=selected runat=server id=lihome><a href=/ISS/home.aspx title=Home><span>Home</span></a></li> Now I
I have below code behind in c# if (Session[cmpDictionaryTitle]!= null) { downloadLinks.Text += @<li><a
I have a repeater which fetches data from a database and shows some labels
I need to retrieve some data from a web page. After analysing the HTML
I have some code in the format below that's repeated throughout my page: <div
I have below code: <a href=# id=@item.Id name=vote ><img src=/Content/images/021.png style=float:left alt= /></a> which
I have below code: class Program { static void Main(string[] args) { Task[] tasks
I have below code to insert a style into DOM (there is a use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.