0

有没有人知道我是怎么来的:

var guests = [];
for (var i = 0; i < parseInt(apartments) ; i++) {
     var pos = i + 1;

     var adults, children, infants;

     adults = $("#adults" + pos).val();
     infants = $("#infants" + pos).val();
     children = $("#children" + pos).val();
     guests.push({ Leg: pos, Adults: adults,
        Children: children, Infants: infants 
     });
}

对于这样的事情:

Guests: [{ Leg: "1", Adults: "2", Children: "0", Infants: "2" },{ Leg:
"2", Adults: "2", Children: "1", Infants: "0" }]
4

1 回答 1

0

利用

JSON.stringify(guests);

我认为应该这样做。

于 2013-01-25T16:38:36.400 回答