I have 4 functions that do something I feel one can do.
function getDownline(rankid, args, type) {
$('body').append('<div class="modal">');
$.getJSON('message_center_getMessageLists.asp', args, function (json) {
var options = '';
$.each(json.downline, function (i, item) {
options += '<option value="' + item.distID + '" title="' + item.name.toLowerCase() + ' (' + item.distID + ')" >' + item.name.toLowerCase() + ' (' + item.distID + ')</option>';
});
$('#fromList').find('option')
.remove()
.end();
$('#fromList').append(options);
})
.success(function () { $('.modal').remove(); })
.error(function () {
alert("There was an error while trying to make this request; If it persists please contact support");
$('.modal').remove();
});
}
The only real difference is the json.downline it can be 4 different things. I added the type param. Which I was trying to use to pass in downline, sponsor, pSponsor or monitorlist.
But I can’t seem to just do json.type, or json. + type any idea what I am missing?
json[type]will get the property named bytype.