I created a Codepen to demonstrate that only the block of code is needed to be inserted on the page, without adding numerous <html>
tags.
http://codepen.io/fernandosavio/pen/EZNEdX
For better visualization I also added the snippet:
// apenas simulando o que deveria ser recebido por ajax
var template = [
'<div class="table-container">',
'<table border="0" width="100%">',
'<tr>',
'<td width="40%" class="infoView torrentNameInf">Filmão</td>',
'<td width="15%" align="center" class="infoView">Filme Bem loko</td>',
'<td width="10%" align="center" class="infoView">1059</td>',
'<td width="10%" align="center" class="infoView">2159</td>',
'<td width="5%" align="center" class="infoView">⬇️</td>',
'</tr>',
'</table>',
'</div>'
].join('');
var container = $('#container');
$('#click-me').on('click', function(){
container.append(template);
});
/* só para ficar mais fácil de ver */
#container { padding: 15px; }
#click-me { margin: 10px; }
.table-container {
margin-bottom: 10px;
}
.table-container table {
background: #CCC;
}
.table-container tr {
height: 35px;
}
.table-container td {
vertical-align: middle;
padding: 3px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="container">
<button id="click-me">Click Me</button>
<div class="table-container">
<table>
<table border="0" width="100%">
<tr>
<td width="40%" class="infoView torrentNameInf">Filmão</td>
<td width="15%" align="center" class="infoView">Filme Bem loko</td>
<td width="10%" align="center" class="infoView">1059</td>
<td width="10%" align="center" class="infoView">2159</td>
<td width="5%" align="center" class="infoView">⬇️</td>
</tr>
</table>
</div>
</div>
That means your file linha.html
should only be
<div class="tableDiv">
<table border="0" width="100%">
<tbody>
<tr>
<td width="40%" class="infoView" id="torrentNameInf">Filmão</td>
<td width="15%" align="center" class="infoView">Filme Bem loko</td>
<td width="10%" align="center" class="infoView">1059</td>
<td width="10%" align="center" class="infoView">2159</td>
<td width="5%" align="center" class="infoView"><img id="downButton" src="images/downButton.png"/></td>
</tr>
</tbody>
</table>
</div>
And your CSS should be on the page where the JS runs.
I also advise you to use only one <table>
and import only the <tr>
Why are you making append of multiple html? including <!doctype>, Stylemain.css, and several tables (you’ll get repeated id’s, #tableDiv) on the same page, that’s not supposed to happen. just try to append the lines you need
– Miguel
@Miguel I need all, actually I wanted to call this div by a PHP function, but as it is not possible I just played in one . html and called for JS.
– Lucas Caresia
Yes, but the file you should call is supposed to contain elements to add to your page (e.g., rows/tables) not an entire document, you should never get repeated ids too, start there
– Miguel
@And how would I call just the
tableDiv
??– Lucas Caresia
I suppose the file where you keep yours
#basetorrent
is already an html document, so you don’t have to charm everything again... Take everything out of the file you call the table and leave it alone,<div class="tableDiv">...
 </div>
... And I didn’t notice it before, but that table wasn’t even inside the tag<body>
– Miguel
It would be easier if there was some code running to test and help you. jsFiddle, Codepen or snippet ?
– fernandosavio
@Miguel I removed everything from inside the . html, I left only the <div>, but still without the margins.
– Lucas Caresia
@fernandosavio I call the files by name, however I did not find how to do it by the sites that passed me.
– Lucas Caresia
@fernandosavio The only problem I’m facing is the fact that CSS does not put the margins on
tableDiv
.– Lucas Caresia
Then do what @Miguel said, just leave the HTML you want to add and not an entire document. I’ll create an answer with an example.
– fernandosavio