Reputation: 70466
It seems impossible to me to realize this array structure
[{ "Field1" : "Foo"}, {"Field2" : "Bar" }]
with following code
var matching = new Array();
$('tr[type="entity"]').each(function(){
var $select = $(this).find('select');
matching[$select.attr('id')] = $select.val();
});
This
alert(JSON.stringify(matching))
returns [ ] always. If it would be php my array would look like that
$matching = array(
"Field1" => "Foo",
"Field2" => "Bar"
);
I know there is no associative array in javascript. However how can I realize such an array based on my code.
Upvotes: 0
Views: 127
Reputation: 179717
Objects are associative arrays. Consider using var matching = new Object();
instead, and check to make sure the function is actually running (i.e. that the tr
you expect actually exist).
Upvotes: 4