Sending javascript array to php
I am trying to send a javascript array to a php for validation. Here is my code:
var elements = new Array();
var values = new Array();
var count = 0;
var i = 0;
$("input").each(function(){
i++;
var ID = $(this).attr("id");
elements = ID;
count = count+1;
});
count = 0;
i = 0;
$("input").each(function(){
// Assign each slot to i's form element
i++;
var value = $(this).attr("value");
values = value;
count = count+1;
});
$.ajax({ url: 'process.php',
data: { submit : "1", elements : elements, values : values },
on process.php:
$values=json_decode($_POST['values']);
$elements = json_decode( $_POST["elements"] );
But when these values are echoed out, they come out to be empty.
