javascript - $.getJSON data into array
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 ;)
Answer
Solution:
Your assignment syntax is wrong. You can't put
[]
at the end of a variable in Javascript.