What is the method for adding an object to an existing javascript object? Below is an example of an existing javascript object
var dataObj = {
TITLE : adtitle,
DESC : addesc,
PRICE : price,
DISCOUNT : discount,
CATID : maincatid,
STATUS : adstatus,
QUANTITY : quantity
};
I have a file object that I would like to add to the above object.
File { name: "paper.jpg", lastModified: 1445433597723, lastModifiedDate: Date 2015-10-21T13:19:57.723Z, size: 54900, type: "image/jpeg" }
This file object is obtained from a file upload input field
var image1 = $('#Image1').prop("files")[0];
var image2 = $('#Image2').prop("files")[0];
Additionally, a $.post
request needs to be executed
$.post("<?php echo Yii::app()->createUrl('/post'); ?>", { jsonData: postdata}, function(response){
console.log(response);
});
All these scripts are triggered upon clicking a button
$('#postit').click(function(e){
//all the mentioned scripts
});