I try to send a JS array to a php file via ajax.
JS code:
$('#basket').on('click',function(){
$.ajax({
type: "GET",
url: "basket.php",
data: {vektor: itemNameArray},
success: function(){
window.location.href ="basket.php";
console.log(itemNameArray);
}
});
});
php code:
<?php
echo("<script>console.log('PHP: test 1');</script>");
if(isset($_GET['vektor'])){
echo("<script>console.log('PHP: test 2');</script>");
$vektor = $_post['vektor'];
echo("<script>console.log('PHP: ".$vektor."');</script>");
}
But it seems that my get with key vektor is not working. I get in LOG my array and the first echo with test 1 but not second. I need to send a array to php file to create a html code. That is becuse I need to open "basket.php" to see result.