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

Java 8 convert Map<Department, List<Person>> to Map<Department, List<String>>

dictionary collections java-8 java-stream

Using Collectors.groupingBy() I can easily obtain a Map&lt;Department, List&lt;Person&gt;&gt; - this gives me all the Person objects that are part of a Department:

How do I draw a shape on an HTML5 video using SVG?

html html5 svg html5-video

I am trying to draw shapes on top of an HTML5 video, but am having trouble figuring out how to do it. I know how to apply a mask on top of the video:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.