I want to send a multi level array via AJAX. so I tried to make an object of objects as follow:
var info = {};
info.pickup = {};
info.pickup.contact = {};
info.pickup.items_quantity = {};
info.pickup.items = {};
info.delivery = {};
info.delivery.contact = {};
info.delivery.level = {};
then I started filling the objects, for example:
$('.operation-create .pickup .contact-details').each(function () {
var arr = {};
arr['contact_name'] = $(this).find('input[name="pickup-contact-name"]').val();
arr['contact_phone'] = $(this).find('input[name="pickup-contact-phone"]').val();
arr['pickup-suburb'] = $(this).find('select[name="pickup-suburb"]').val();
arr['single-pickup-address'] = $(this).find('input[name="single-pickup-address"]').val();
info.pickup.contact.push(arr);
});
info.pickup.push(info.pickup.contact);
etc...
However unfortunately it didn't work. I get this error:
info.pickup.contact.push is not a function
What I should do here? What is the right way to send this array via AJAX?
contactto an array:info.pickup.contact = [];info.pickupas array with pushing objects, likeinfo.pickup.contactand at the same time, you use it as plain object with custom properties.