i'm new in PHP and JAVASCRIPT..
i need to do a little script who takes the data from data.php with
$.getJSON("data.php", function(json).. and push it into 2 arrays in the HTML file, to reuse them.
data.php produce this:
[[47,48,48,48,50,51,48,46,47,45,48,47],[25,23,22,21,19,21,24,25,27,29,31,28]]
at now i do this, but it doesn't run and i don't know how to do.
<!DOCTYPE html>
<html>
<head>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
$.getJSON("data.php", function(json) {
$row1[] = json[0];
$row2[]= json[1];
});
});
</script>
</head>
<body>
<div></div>
</body>
</html>
thanks to all guys ;)
$array[]means to append data to an array in PHP, not JavaScript. Whereasobject[property]is to access an object's property value. However,$row1[]in your code is an invalid syntax as you have not defined any object$row1nor provided any property within[].