im new to Javascript and im struggling with this question for a while.
I have a dynamic jquery table and my goal is to hyperlink one row of that table (the row data) to a .php page to make some queries.
My objective is something like this:
for example, in the table
data info money name ID
20161001 ... 34 test 1010
20161002 .... 20 dddd 111
20161003 ... 12 .... .....
users could press 20161001 or 20161002 and this would link to a detailed table with all the info of this day
My first problem is to reach the object inside the array of data.
Every time i try to reach data i got something like : [Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object]
The only way i could reach them was from:
JSON.stringify(data[i])
i made a for statement but this return all the info from table and i just need the data from the row: Data.
for my dynamic table i get the headers from :
var keys=[];
for (var key in data[0]) {
keys.push(key);
}
I also try to combine this 2 ways to reach the info but no success.
My ajax code:
$.ajax({
type: 'post',
url: "data.php",
dataType: "json",
data: $(this).serialize(),
success: function(data) {
console.log(data);
$('#btn-load').click(function(e) {
var keys=[];
for (var key in data[0]) {
keys.push(key);
}
dt = dynamicTable.config('data-table', //id of the table
keys, //field names
null, //set to null for field names to be used as header names instead of custom headers
'no data...');
dt.load(data);
});
(Dynamic table with code of this page: Dynamically update a table using javascript)
I need to reach this info, link him and pass the value into a php page.
I don't know if this method is the more appropriate so if someone can give me some lights i would appreciate.
Thanks