我有4个功能可以做我觉得可以做的事情。
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();
});
}
唯一真正的区别是json.downline
它可以是4种不同的东西。我添加了type
参数。我试图用它来传递downline, sponsor, pSponsor or monitorlist
。
但我似乎只是json.type
或json. + type
知道我错过了什么?
答案 0 :(得分:1)
json[type]
将获取type
命名的属性。