I have two functions that are very similar and I would like if possible to combine them. The only issue that I have is one function is accepting 2 arguments and the other one is accepting 3. Is there a way to do this or these two functions have to stay separated by design?
function getClientData(id, command) {
var formData = {
'method': command,
'id': id
};
getEntityData(formData);
}
function getLocation(id, clientid, command) {
var formData = {
'method': command,
'locationid': id,
'clientbrandid': clientid
};
getEntityData(formData);
}
Update
function getEntityData(data) {
var url = '/../admin/miscellaneous/components/global.cfc?wsdl';
var ajaxResponse = $.ajax({
url: url,
dataType: 'json',
data: data,
global: false,
async:false,
cache: false,
success: function(apiResponse){
return apiResponse;
}
}).responseJSON;
var response = ajaxResponse[0];
for (var i in response) {
if (response.hasOwnProperty(i)){
$("#edit"+i).val(response[i].trim());
}
}
}
data:section.