문제

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?

도움이 되었습니까?

해결책

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

Note

serializeArray() give the output like:

[
 {
   test: 1
 },
 {
   test: 2
 },
 ...
]

다른 팁

Use this instead:

console.log( test[ index ] );
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top