How can I assign a variable to content attr of dojo.xhrPost dynamically ? Below is the code and some explanation for my scenario:
Code with hard coded values for content
dojo.xhrPost({
url: /esturl/,
handleAs : "text",
content : {INST1 : '{"0001" : "aa"}',
INST2 : '{"0002" : "bb"}',
INST3 : '{"0003" : "cc"}'}
load : load(data),
error : error
});
The number of INST in Content attr can be minimum 1 and max 6, as of now I am hard coding 3 pairs there.
But I want to have one var
like buildJason
var buildJson = function (){
}
And this var will populate dynamic value to content attr
.
I am having "0001" "aa"
values from
var element = dojo.query('input:checked');
element.id;
But everytime user checks different box than depending upon user selection values for content attr should be dynamically populated, any suggestion as to how this can be achieved ?
Update
After using approach suggested by CastroXXL
, am getting following error message on firebug.
missing : after property id
var myContent = {};\n
Any suggestions as to how I can deal with it ?