I'm trying to create a json object in javascript containing dynamic values. I need to pass this JSON Object to server through an AJAX call. But I'm unable to add the dynamic values.
var finalJSONObj={};
for loop(int i = 0; i<10;i++){
// gets the values of rows i need to add ..
var taskValue = tasks[i]; // need to add this in the JSON Object
}
My final JSON object should look like:
finalJSONObj = {
tasks1: 'taskValue',
tasks2: 'taskValue',
tasks3: 'taskValue',
tasks4: 'taskValue',
userId: 'abcd',
date: '23/09/2016'
};
Need to add the "taskValue" retrieved from the for loop for each task in the JSON Object. Any Thoughts?