guys, I would like to solve this I been stuck 2days on it, so i want to put in the table 2 value the one who say rank: 9074838 and the one in top 1 , value: 33 I have a .json file named: greenz_lewis.json who look like this
{
"accountId": "6df47486-86d6-4b4b-a5e7-4c6b1b8c9322",
"user": "greenz_lewis",
"stats": {
"p2": {
"score": {
"label": "Score",
"category": "General",
"rank": 9074838,
},
"top1": {
"label": "Wins",
"value": "33",
}
}
}
and I have my PHP file who looks like this
<?php
session_start();
if ( $_SESSION['logged_in'] != 1 ) {
$_SESSION['message'] = "You must log in before viewing your profile page!";
header("location: error.php");
}
else {
// Makes it easier to read
$username = $_SESSION['username'];
}
?>
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script>
</head>
<body class="is-preload">
<section id="main" class="wrapper">
<div class="inner">
<table id="stats1">
<th>solo wins</th>
<th>duos wins</th>
<th>squad wins</th>
<th>total killz</th>
</table>
<script>
$(document).ready(function(){
$.ajax({
url:'userstats/<?=$_SESSION['username'] ?>.json',
dataType:"json",
success:function(data){
$(data.stats).each(function(index,value){
var record="<tr><td>"+(top1)+
"</td><td>"+top1.label+"</td><td>"+
top1.value+"</td>"
"</td></tr>";
$("table").append(record);
});
}
});
});
</script>
</div>
</section>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.scrollex.min.js"></script>
<script src="assets/js/jquery.scrolly.min.js"></script>
<script src="assets/js/browser.min.js"></script>
<script src="assets/js/breakpoints.min.js"></script>
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>
so it doesn't work I have tried like 5 different ways this is the closest one

eachcallback to console so you can inspect what they are and react accordingly. Can't just make up variables liketop1and expect them to be defined out of thin airconsole.log(someVariable)and open browser dev tools console (F12) to inspect output