The output of this code:
<?php
echo "<script type='text/javascript'> $('#query-info').append('<div class=\"well\">')</script>";
foreach ($_POST as $key => $entry)
{
echo "<script type='text/javascript'> $('#query-info').append('". $key . ": " . $entry . "<br />')</script>";
}
echo "<script type='text/javascript'> $('#query-info').append('</div>')</script>";
?>
is:
<div class="well"></div>
itemID: 1
<br>
</div>
Note the extra unwanted (first) closing div.
.appendcan only append HTML nodes, it can’t just append opening or closing tags.Have PHP generate the entire
<div>, then.appendthe whole thing.