I have a multiple select box, and I want to pass the selected contents to a php script to use in a db lookup. But I just can't get it to pass an array at all.
I'm testing now with trying to pass a direct array (not via the select), myArr, and it still only passes one of the values in the array:
So using the post method here to getseldb.php, passing in selectHandle and myArr, and getting back dataout. Then I just print what it gets back to the console.
My php code just looks like this to echo the input data:
The console spits out this:
I'm testing now with trying to pass a direct array (not via the select), myArr, and it still only passes one of the values in the array:
So using the post method here to getseldb.php, passing in selectHandle and myArr, and getting back dataout. Then I just print what it gets back to the console.
Code:
var myArr= ["test1", "test2"];
$.post('getseldb.php', {select: selectHandle, data_in: myArr}, function(dataout) {
console.log(dataout);
});
My php code just looks like this to echo the input data:
Code:
print_r($_POST);
The console spits out this:
Code:
Array
(
[select] => selectID
[data_in] => test2
)