I was trying to send an associative array of warnings when a button is clicked. It will pass id and type of warning and trigger collect function which stores them into the array as key value pairs. Then I want to send it to another page. The problem is if it is simple array it will work when I call $_POST ['warn']; but if I change it to an associative array I will get error msg saying that warn is not defined. This is my JS code:
var warnings = [];
function collect(id,type){ warnings [id] = type;}
$('#but1').click (function (){
$.post ("url", {warn: warnings}function(r){alert (r);});
});
Is there a way to send the associative array as key value pairs using AJAX to my php page and get the array using $_POST?
$.postcall, but that would have caused other issues, so I'm guessing that's a typo.warnings = {};.