I need to pass valuesArray to php if button is clicked, when anotherButton is clicked, i want to print this array in PHP.
home.js:
button.onclick = function (){
valuesArray = ['a', 'b', 'c']
$.post('index.php', {data: valuesArray});
}
index.php:
<?php
If(isset($_POST['anotherButton'])){
$getData = $_POST['data'];
print_r($getData);
}
?>
If button gets clicked I get
undefined index: data
which should mean that data wasn't passed to PHP.