I'm trying to dynamically build an object with key:[value array], however using different methods I keep ending up with a singular item in the value array (where in the response there are multiple values).
Psuedocode:
var myFunction = function () {
var myObject = {};
$.ajax('http://the.url.com', {
type: "GET",
success: function (res) {
$(res).each(function (i, v) {
var name = v.name;
var id = v.id;
// create object with building block and tech id to associate techs to BBs
myObject[name] = new Array();
myObject[name].push(id);
});
},
error: function (xhr) {}
}
}
Current output:
{
key1: ["value1c"]
key2: ["value2a"]
key3: ["value3b"]
}
Desired output:
{
key1: ["value1a", "value1b","value1c"]
key2: ["value2a"]
key3: ["value3a", "value3b"]
}