首页 > 技术文章 > 一段诡异的代码,没理解

MorZe 2015-01-29 21:16 原文

var cableProjectAddressBList = [];
function getCableProjectAddressBList(cableTypeCode, cableId, cableAPositionName) {
    
    cableAPositionName = encodeURIComponent(cableAPositionName);
    if (cableTypeCode && cableId && cableAPositionName) {

        $.ajax({
            dataType: "json",
            url: "ajax.aspx",
            data: {
                operationType: 'getCableProjectAddressBList',
                cableTypeCode: cableTypeCode,
                cableId: cableId,
                cableAPositionName: cableAPositionName
            },
            success: function (data, textStatus, jqXHR) {
                // 如果重新声明对象那么,外部的cableProjectAddressBList不会被改变,疑惑中
                //cableProjectAddressBList = [];
                cableProjectAddressBList.length = 0;
                for (var i in data) {
                    cableProjectAddressBList.push(data[i].Address);
                }
            }
        });
    }
}

  

推荐阅读