I'm confused about how associative indexing and javascript.
In my javascript, I do this:
$("input[type=button]").click(function () {
var checked = {};
$('input[type=checkbox]').each(function() {
if ($(this).is(':checked')) {
checked[$(this).attr('name')] = $(this).val();
}
});
var value = [];
value.push($(this).siblings("input[type=text]").val());
$.ajax({ url: "scripts/php/generatehtml.php",
data: {action: value},
type: 'post',
dataType: "json",
success: ...<cut for brevity>});
So in my PHP code, I do this:
if (isset($_POST['action']) && !empty($_POST['action'])) {
var_dump($_POST['action']);
}
And get this:
array(1) {
[0]=>
string(5) "12277"
}
As you can see, that's an indexed array, I want an associative array. But whenver I do something like:
value['id'] = $(this).siblings("input[type=text]").val()
Nothing gets sent.
I'm not very good wtih Ajax, and any help here would be really great!
NOTE: I did look at the other ajax array answers, but I don't think they answer my question.