If I have an object array like this…
var p = [{ 'first': 'John', 'last': 'Doe' }, { 'first': 'Sue', 'last': 'Smith' }];
And I need to append it to the URL like this…
/myapp/myaction?p[0].first=John&p[0].last=Doe&p[1].first=Sue&p[1].last=Smith
Is there something in JQuery that will help me do this without having to process it manually?
Basically, I have an object like the people array, and I need to send it to ASP MVC3 in a format that it will understand and bind to a list. MVC3 understands nested items encoded in the “dot” format (e.g. p[0].first).
There may be an even better way, but something like this should work:
If the properties of the objects are dynamic, you could use a
for...into loop over them.