Hi,
This result;
[{"bakfile":"~\/DB-Web\/accounts\/ACCOUNTS_DUMP_06.16.14_11.30.27.sql.gz"},{"bakfile":"~\/DB-Web\/contacts\/CONTACTS_DUMP_06.16.14_11.30.07.sql.gz"}]
is what is returned from the PHP code shown below.
The <script> is what I am trying to read the "data" from. It gives me "bakfile undefined" as the result. I'm thinking this is some stupid thing I am doing but I can't figure it out. Any help here appreciated !!!
Code:
<script type="text/javascript" >
$(function() {
$.ajax({
type: "POST",
url: "restore.php",
datatype:"json",
success: radioPick // <<= === === CALLBACK FUNCTION
}); // ajax
function radioPick(data) {
alert("\nbakfile\n"+ data[0].bakfile);
}
});
</script>
And the Server Code PHP
Code:
$rows=array();
$cxn = mysqli_connect($hostname,$username,$password,$database)
or die ("couldn't connect to server");
$query = "SELECT bakfile FROM ".$table." ORDER BY bakfile";
$result = mysqli_query($cxn,$query) or die ("Couldn't execute query.");
while($row = mysqli_fetch_assoc($result)) {
//extract($row);
//if($row['bakfile']=="") { continue;}
$rows[]=$row;
}
echo json_encode($rows);