Hello I am doing some research on this topic. My knowledge of jquery and PHP are limited but I think this could be pretty easy to do, if you guys could point me in the right direction I would really appreciate it.
My goal is to append two rows of static data vs just one. I know I need to change the array so it spits out two data sets and then change the jquery method to handle the two sets, but I don't have enough knowledge to change it and make it scale so if I need to handle 30 sets off data it can.
my environment:
jquery append row based on json data received from php file.
PHP Code:
$(document).ready(function() {
$("#btnAdd").click(function() {
// get data
$.ajax({
url: '/ajax/data.php',
type: "GET",
cache: false,
error: function(data) {
$("div#error").html('error: '+data);
},
success: function(data) {
var json = jQuery.parseJSON(data);
var newRow = $("<tr><td>"+json.icon+"</td><td>"+json.app+"</td><td>"+json.timestamp+"</td><td>"+json.location+"</td><td>"+json.comments+"</td></tr>");
$("#mainTable tbody").append(newRow);
}
});
});
});
php associative array that produces the data.
PHP Code:
<?php
$retArray = array();
$retArray['icon'] = 'icon';
$retArray['app'] = 'GGP';
$retArray['timestamp'] = date('m/d/Y');
$retArray['location'] = 'Bellevue';
$retArray['comments'] = 'It works!';
echo json_encode($retArray);
?>
thanks - Micah