The end result needs to look something like this:
Name1: "John"
Name2: "Johnson"
Age: "30"
City: "Atlanta"
State: "GA"
I'm trying to push objects into a single object, but what its doing is creating an array with multiple objects that I can't make a single call ( like if I wrapped all the data above in variable newData, I could just call newData[0] and it would return the above ). Currently, I'm trying it like this:
var newData = [];
$(data).each(function (i, value) {
var getTitle = $(value).attr('data-title'); // Returns title
var getData = $(value).val();
newData.push({ getTitle : getData });
});
This code produces a result like:
0:{ getTitle : "John" }
1:{ getTitle : "Johnson" }
2:{ getTitle : "30" }
3:{ getTitle : "Atlanta" }
4:{ getTitle : "State" }
So not sure what I'm doing wrong.