Forum Discussion
_anomDiebolt_
8 years agoQrew Elite
Your code is a mess. You need to merge the different sets of options objects together using native JavaScript Object.assign() or jQuery.extend().
I don't have your F* variables you so I just converted them to string values in the following code.
The first and second console.logs will display as follows depending on for F9 equal to "1" or "2" as follows:
I don't have your F* variables you so I just converted them to string values in the following code.
var options1 = {
act: "API_AddRecord",
_fid_48: "F72",
_fid_132: "F77",
_fid_150: "F98",
_fid_147: "F84",
_fid_77: "F100",
}
var options2 = {
_fid_137: "F21",
_fid_251: "F22",
_fid_442: "F23",
_fid_164: "F999",
}
var options3 = {
_fid_137: "F21",
_fid_251: "F22",
_fid_442: "F23",
_fid_164: "F999",
_fid_138: "F25",
_fid_252: "F26",
_fid_443: "F27",
_fid_165: "F999"
}
var F9 = "1";
var options;
switch (F9) {
case '1':
options = Object.assign({}, options1, options2)
break;
case '2':
option = Object.assign({}, options1, options3)
break;
}
console.log(JSON.stringify(options, null, " "));
var F9 = "2";
var options;
switch (F9) {
case '1':
options = Object.assign({}, options1, options2)
break;
case '2':
options = Object.assign({}, options1, options3)
break;
}
console.log(JSON.stringify(options, null, " "));
$.get(dbidWR, options)
.then(function(xml) {
console.dirxml(xml)
});
The first and second console.logs will display as follows depending on for F9 equal to "1" or "2" as follows:
{
"act": "API_AddRecord",
"_fid_48": "F72",
"_fid_132": "F77",
"_fid_150": "F98",
"_fid_147": "F84",
"_fid_77": "F100",
"_fid_137": "F21",
"_fid_251": "F22",
"_fid_442": "F23",
"_fid_164": "F999"
}
{
"act": "API_AddRecord",
"_fid_48": "F72",
"_fid_132": "F77",
"_fid_150": "F98",
"_fid_147": "F84",
"_fid_77": "F100",
"_fid_137": "F21",
"_fid_251": "F22",
"_fid_442": "F23",
"_fid_164": "F999",
"_fid_138": "F25",
"_fid_252": "F26",
"_fid_443": "F27",
"_fid_165": "F999"
}