2012-03-26 11 views
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 paramを追加しました。私はdownline, sponsor, pSponsor or monitorlistで渡すために使用しようとしていた。

しかし、私はちょうどdoすることはできませんjson.type、またはjson. + type私は行方不明何か?

答えて

1

json[type]は、typeという名前のプロパティを取得します。

+0

これはトリックでした、ありがとうございます。 –

関連する問題