Having trouble cleaning up my code
<p>I have 4 functions that do something I feel one can do.</p>

<pre><code>function getDownline(rankid, args, type) {
    $('body').append('&lt;div class="modal"&gt;');
    $.getJSON('message_center_getMessageLists.asp', args, function (json) {
        var options = '';
        $.each(json.downline, function (i, item) {
            options += '&lt;option value="' + item.distID + '" title="' + item.name.toLowerCase() + ' (' + item.distID + ')" &gt;' + item.name.toLowerCase() + ' (' + item.distID + ')&lt;/option&gt;';
        });

        $('#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(); 
     });
 }
</code></pre>

<p>The only real difference is the <code>json.downline</code> it can be 4 different things.  I added the <code>type</code> param.  Which I was trying to use to pass in <code>downline, sponsor, pSponsor or monitorlist</code>.</p>

<p>But I can't seem to just do <code>json.type</code>, or <code>json. + type</code> any idea what I am missing?</p>
