How to add a value in a json subarray with jQuery?

How to add a value in a json subarray with jQuery ?

I has build this code but it dosen't work... The developer console tell me "Cannot call method 'push' of undefined"

function save(){
    var Arguments = [];
    $('.builder-page').each(function(){
        var title = $(this).find('input[name=title]').val();
        Arguments.pages.push({'title':title})
    });
    console.log(Arguments);
}

Thanks !

Answers


You need to declare it as on object which has an array as its pages property.

var Arguments = {pages: []};

Need Your Help

Personalized app version

ios iphone ad-hoc-distribution

I have a problem with my application on Appstore. There are a few clients on whose device the app failed to install or hangs ( something happened during the database update/migration, but not crash...

Why I'm getting junk data in the File?

java file byte fileinputstream fileoutputstream

I'm receiving a File from server and in client I want to save this file to a directory. Here is the code that do the job of saving the File