I have a function that calls an ajax, inside that ajax another ajax needs to be executed. In the below code I gave my full function. Just to ensure that everything but the 2nd ajax works perfectly, I should point you out that before the 2nd ajax call there is an alert() function which works. That means everything works if I comment the 2nd ajax call. If I uncomment it then after the first alert a second alert should appear saying 'inside 2nd call', but nothing happens. Got any suggestions?

function get_employee_list(Parameter){

    url: 'resource/php/search_profile.php',
    type: 'POST',
    data: { var1 : Parameter},
    async: false,
    success: function (response) {
        $(response).find('employee').each(function() {
            var ebasp_id = $(this).find('ebasp_id').text();
            var ebasp_name = $(this).find('ebasp_name').text();
            var ebasp_gender = $(this).find('ebasp_gender').text();
            var ebasp_category = $(this).find('ebasp_category').text();
            //var ebasp_region_type = $(this).find('ebasp_region_type').text();
            //var ebasp_region_name = $(this).find('ebasp_region_name').text();
            var code_sub_region = $(this).find('ebasp_sub_region').text();
            var code_location = $(this).find('ebasp_location').text();
            var code_office = '';

            if (code_location === '0')
                code_office = code_sub_region;
                code_office = code_location;
            var office = '';

            //alert('before 2nd call -- '+code_office);
                url: 'resource/php/show_cost_center_name.php',
                type: POST,
                data: { var1 : code_office},
                success: function(response){
                    office = response;
                    alert('inside 2nd call');

            var ebasp_designation = $(this).find('ebasp_designation').text();
            var ebasp_date_of_joining = $(this).find('ebasp_date_of_joining').text();
            var ebasp_grade = $(this).find('ebasp_grade').text();
            var ebasp_slab = $(this).find('ebasp_slab').text();
            var ebasp_basic = $(this).find('ebasp_basic').text();
            var ebasp_photo_upload = $(this).find('ebasp_photo_upload').text();
            var ebasp_created_on = $(this).find('ebasp_created_on').text();
            var ebasp_created_by = $(this).find('ebasp_created_by').text();

    cache: false,
});return false;
2016/02/12 09:26
  • ajax
  • 点赞
  • 收藏
  • 回答