Remplir la table html jQuery succès de l'événement
Voici mon problème.
J'ai ce tableau html:
<table class="flexme" id="table" border="1">
<thead>
<tr>
<th width="100">Usuario</th>
<th width="100">Nombre</th>
<th width="100">Apellido</th>
<th width="100">Cedula/Rif</th>
<th width="140">Direccion</th>
<th width="100">E-mail</th>
<th width="100">Telefono1</th>
<th width="100">Telefono2</th>
<th width="100">Status</th>
<th width="150">Acción</th>
</tr>
</thead>
<tbody>
<tr id="test">
<td></td>
</tr>
</tbody>
</table>
et j'ai cette requête ajax:
$.ajax({
type : "POST",
url : "service.php",
dataType: "json",
data: {
action:"search",
type: 'users',
parameter: parameter,
parameterContent: parameterContent,
},
success:function(data) {
$('#searchResults').show();
var len = data.length;
for (var i = 0; i< len; i++) {
var username = data[i].username;
var name = data[i].uname;
var lastname = data[i].lastname;
}
})
Quelle est la bonne façon de remplir le tableau html avec l'info qui vient via JSON? J'ai essayé, sans succès. J'ai fait des essais avec append()
html()
mais sans succès, à tous, quelqu'un peut-il svp me pointer dans la bonne direction?
Ce que je veux, c'est prendre l'info qui vient via JSON et remplir le tableau dynamiquement avec cette info.
- Avez-vous essayé
load()
? api.jquery.com/load - pourriez-vous s'il vous plaît montrer l'extrait de code qui était en train de préparer le TRs de la réponse JSON? Et comment vous essayez de les ajouter à la TBODY?
- Savez-vous à propos de datatables.net?
Vous devez vous connecter pour publier un commentaire.
Vous pouvez essayer ceci:
Plus d'informations peuvent être trouvées ici:
http://api.jquery.com/jQuery.each/
Essayez ceci:
Grâce, à la fin j'ai fait comme ceci: