-1

hi i am updating the keyIndex array, which is created in object, while i add the array to URL it's not work:

my code :

var dataObject = {
    Indices: {
        subIndex: {
            keyIndex: [], //this is not updating in baseURL 'keyIndex'
            method: 'GetCCINationalIndicesData',
            baseURL: 'http://107.20.173.235/BlufinAPI/Service/ConsumerConfidenceIndex.svc/GetCCINationalIndicesData?InputJSON={"IndexID":"' + keyIndex + '","FromMonth":"10","FromYear":"2011","ToMonth":"3","ToYear":"2012"}'
        }
    },
    Geography: {
        0: '1',
        tiers: {
            method: 'GetCCITierIndicesData'
        },
        regions: {
            method: 'GetCCIRegionIndicesData'
        },
        city: {
            method: 'GetCCICityIndicesData'
        }
    },
    Demographics: {}
}

anything wrong?

4

1 回答 1

2

这是因为在创建字符串keyIndex时只评估一次。baseURL

您可以baseURL改为创建一个函数...

baseURL:function() {
    return 'http://107.20.173.235/BlufinAPI/Service/ConsumerConfidenceIndex.svc/GetCCINationalIndicesData?InputJSON={"IndexID":"' + 
            this.keyIndex + 
            '","FromMonth":"10","FromYear":"2011","ToMonth":"3","ToYear":"2012"}';
}

然后像函数一样调用它......

dataObject.Indices.subIndex.baseURL();

尽管最初keyIndex不是对对象属性的引用。

这与jQuery无关。

于 2012-04-09T15:05:11.633 回答