Merge the HTML table called with Ajax

Hello,

How can I combine this table?
Automatically adds the label "</tr> </table>" to the end of the table I call with Ajax
Is it possible to prevent this?

index.php

   <table border="1" width="40%" id="dynamic_content">
            <td>&nbsp;</td>
	    <td>&nbsp;</td>
	</tr>
</table>

$.ajax({
        url:"ajax.php",
        method:"POST",
        success:function(data)
        {
        $('#dynamic_content').html(data);
        }
    });

ajax.php

	<tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>

The code you have now is replacing the existing table content with whatever is received from the ajax call. If you want to merge/combine the new row(s) with whatever already exists in the table, you will need to append the new row(s) to the table.

That’s because the html markup you are sending is incomplete and invalid. The browser must therefore add enough to it so that it can be rendered and displayed on the page. Why are you not sending complete and valid html to the browser?

The paging code I mentioned in the previous topic
Rows and pagination links come from ajax.php

As in the picture below


“search and show 10 lines on the page”
I had to use the second line for options
I want to add to the right of pagination links

But I found a solution
I created separate variables for rows in ajax.php, and separate variables for pagination links

$rows = 
$page_link =

$jsonData = array(
  "rows"  => $rows, "page_link" => $page_link,
);
echo json_encode($jsonData);

in index.php

<tabel id="rows">
</table>

<table>
<td><div id="page_link"></div></td>
<td>search and show 10 lines on the page</td>
</table>

success:function(data)
        {
          $('#rows').html(data.rows);
          $('#page_link').html(data.page_link);
        }

and the result

I hope this is the right coding

Sponsor our Newsletter | Privacy Policy | Terms of Service