0

I have inputs like this:

<input name="val[test]" value="...">

I am trying to get all values with a jQuery's serializeArray, but it wont work.

I am doing:

var test = $('#myForm').serializeArray();
debug(test.val[test]);

Its not working, why?

simshaun
  • 21,263
  • 1
  • 57
  • 73

2 Answers2

0
var test = $('#myForm').serializeArray();
$.each(test, function(index, val) {
  console.log( val.test );
});

Note

serializeArray() give the output like:

[
 {
   test: 1
 },
 {
   test: 2
 },
 ...
]
thecodeparadox
  • 86,271
  • 21
  • 138
  • 164
0

Use this instead:

console.log( test[ index ] );