如何从ajax函数访问对象?

时间:2014-10-24 01:58:43

标签: javascript ajax

我需要访问在ajax函数中创建的对象以继续使用方法...

$.ajax({
    type: "POST",
    url: '../GeneralManager/Sales/DAOs/CompPSMCQuery.php',
    data: {compRangeY1: rangeY1,
        compRangeY2: rangeY2,
        compRangeM1: rangeM1,
        compRangeM2: rangeM2},
    success: function (data)
    {
        var arr = [];
        arr = JSON.parse(data);
        var asList = [], tcList = [], acList = [], yearList = [], monthList = [];
        for (var x = 0; x < arr.length; x++) {
            asList.push(Number(arr[x].actualSales.replace(/[^0-9\.]+/g, "")));
            tcList.push(Number(arr[x].transactionCount.replace(/[^0-9\.]+/g, "")));
            acList.push(Number(arr[x].averageCheck.replace(/[^0-9\.]+/g, "")));
            yearList.push(Number(arr[x].calYearNum.replace(/[^0-9\.]+/g, "")));
            monthList.push(Number(arr[x].calMonthNum.replace(/[^0-9\.]+/g, "")));
        }

        obj1 = {
            name: 'Period 1',
            asList: asList,
            tcList: tcList,
            acList: acList,
            yearList: yearList,
            monthList: monthList
        };
    }
});

您认为我需要访问ajax以外的obj1 ...

0 个答案:

没有答案