This is my function that get's all the id's ad stores them in an array them it sends the array to the php page. Using google chrome network tool i can see the request which has the array in the header.
$(document).ready(function() {
$("#insert_articoli").click(function(){
var id_articoli = [];
$.each($("input[name='articoli']:checked"), function(){
id_articoli.push($(this).val());
});
$.ajax({
type: "POST",
url: "componi_prodotto.php",
data: {data : id_articoli },
success: function(){
alert("OK");
}
});
});
});
I can't find a way to retrieve this array from my php page. Please help.
Make sure you're echoing something in your PHP, then you need to have something to return to, so set a variable in the success function:
success: function(response){ // whatever is echoed in PHP will be in 'response'
console.log(response);
}
Please, quit using alert()
for troubleshooting., use console.log()
instead.