0
我有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
任何想法我失踪?
这样做的伎俩,谢谢。 – 2012-03-26 17:32:12