I try to use result of ajax in outer of ajax method and wrote this code but get error that :
TypeError: foods is null    
for (var j = 0; j <foods.obj.length; j++) {
$(document).ready(function () {
            var foods = null;
            $.ajax({
                url: '/Train/TrianFood',
                data: { Tarrif: 1 },
                type: "POST",
                context: this,
                success: function (result) {foods = result;},
                error: function () {}
            });
            var parentOfFood = $('#accordion1 .person-information');
            for (var i = 0; i < parentOfFood.length; i++) {
                var foodSelect = $(parentOfFood[i]).find('select[name$=Food]');
                for (var j = 0; j <foods.obj.length; j++) {
                    foodSelect.append(new Option(foods.obj[j].ServiceType, foods.obj[j].ServiceTypeCode));
                }
            }
       });

 
     
     
     
     
    