Javascript 在DOM ready上使用$.each创建函数

Javascript 在DOM ready上使用$.each创建函数,javascript,jquery,Javascript,Jquery,我试图迭代jsonarray,以便在其他函数中使用这些值。但我不太明白如何创建这样的函数以及如何返回值。我正在使用以下代码: (function($) { $.fn.loopThroughCurrent = function() { console.log(currentJson); $.each(currentJson, function(k,v) { firstTypeValue= k; console.

我试图迭代jsonarray,以便在其他函数中使用这些值。但我不太明白如何创建这样的函数以及如何返回值。我正在使用以下代码:

(function($) {
    $.fn.loopThroughCurrent = function() {
        console.log(currentJson);
        $.each(currentJson, function(k,v) {
            firstTypeValue= k;
            console.log(firstTypeValue);
            $.each(v, function(k,v) {
                secondTypeValue= k;
                console.log(secondTypeValue);
                $.each(v, function(k,v) {
                    year = k;
                    console.log(year);
                    $.each(v, function(k,v) {
                        month = k;
                        console.log(month);
                        $.each(v, function(k,v) {
                            id = v.id;
                            startDate = v.startDate;
                            endDate = v.endDate;
                            price = v.price;

                            console.log('id: ' + id);
                            console.log('startDate: ' + startDate);
                            console.log('endDate: ' + endDate);
                            console.log('price: ' + price);
                        })
                    })
                })
            })
        });
        return ?
    };
}(jQuery));

$(document).ready().loopThroughCurrent();
以下json数组:

{
    "Clienten en patienten": {
        "Weekend": {
            "2015": {
                "05": [
                    {
                        "id": 105,
                        "startDate": "01-05-2015",
                        "endDate": "04-05-2015",
                        "price": 645
                    }
                ]
            }
        }
    }
}
完成后,我将使用一系列函数中的值最终填充SelectBox和textfields,如下所示:

$(document)
    .ready(changeFirstType(firstTypeValue))
    .ready(changeSecondType(secondTypeValue))
    .ready(getMonths(year))
    .ready(getDates(month)).ready(function() {
        $("select[name='year'] option:eq(1)").attr('selected', 'selected');
        $("select[name='month'] option:eq(1)").attr('selected', 'selected');
        $("select[name='startDate'] option:eq(1)").attr('selected', 'selected');
        $("input[type='radio'][name='dateType'][value='"+ secondTypeValue+"']").prop('checked', true);
    })
    .ready(getEndDate()).ready(function() {
        $(endDateText).val(" tot: " + endDate);
        $(priceText).val(" \u20AC " + price + ",-");
    });
如果需要任何其他信息,请询问。这是新的。
提前谢谢