I have a ajax script that returns me an associative array list as follows:
array(24) {
["id"]=>
string(4) "3478"
["joindate"]=>
string(19) "2016-10-17 21:20:28"
["ip"]=>
string(12) "xxx.xxx.xx.xx"
...
}
array(24) {
["id"]=>
string(4) "3479"
["joindate"]=>
string(19) "2016-10-17 21:20:28"
["ip"]=>
string(12) "xxx.xxx.xx.xx"
...
}
HTML
<thead>
<tr>
<th><b><u>key 1</u></b></th>
<th><b><u>key 2</u></b></th>
<th><b><u>key 3</u></b></th>
<th><b><u>key 4</u></b></th>
<th><b>etc...</b></th>
</tr>
</thead>
<tbody>
<tr>
<td>value 1</td>
<td>value 2</td>
<td>value 3</td>
<td>value 4</td>
<td>etc...</td>
</tr>
<tr>
<td>value 1</td>
<td>value 2</td>
<td>value 3</td>
<td>value 4</td>
<td>etc...</td>
</tr>
</tbody>
My current javascript where formation is an ID and methode is my date
data += "data=" +formation+' '+methode;
$.ajax({
url: "core/display_lead.php",
type: "post",
data: data, dataType: "html",
success : function(code_html, statut){
console.log(code_html);
},
error : function(resultat, statut, erreur){
console.log("La requête n'a pas aboutie...");
console.log(resultat);
console.log(statut);
console.log(erreur);
}
});
how do I get the key to creating a table header, then only the value to fill it ?
For the moment I transmits data to Javascript with a simple PHP var_dump, there is a cleaner method, perhaps?
thanks a lot