pass associative arrays through post
Hello - I have searched quite a bit through these discussions but
cannot seem to find an answer to this question:
I have an associative array in javascript like this:
params = new Array();
params['test_id'] = test_id;
params['another_id'] = another_id;
params['action'] = 'confirm'
Then, I am calling post through jQuery like this:
$j.post("HandleAjaxCall.php", {controller: 'TestName', method:
'process_test', params: params},
function(data) {
alert('Completed! Data: ' + data);
}
);
Now, how do I pass the associative array in js to be able to read it
in PHP? This is basically a dynamically created parameters that I am
not going to know ahead of time. So, I need to be able to (in php) be
able to read this array like this:
<?php
class TestName {
function process_test() {
$params = $_POST['params'];
echo "ID is: " . $params['test_id'];
}
}
?>
Is there a way to do this?
Thanks!