weixin_33712987 2016-02-12 09:26 采纳率: 0%
浏览 17

Ajax中的Ajax无法正常工作

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){

$.ajax({
    url: 'resource/php/search_profile.php',
    type: 'POST',
    data: { var1 : Parameter},
    async: false,
    success: function (response) {
        //alert(response);
        reset_search_table();
        $(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;
            else
                code_office = code_location;
            var office = '';

            //alert('before 2nd call -- '+code_office);
            $.ajax({
                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();

            $("#search_table").show();
            $('<tr></tr>').html('<td>'+ebasp_id+'</td>'+
                                '<td>'+ebasp_name+'</td>'+
                                '<td>'+ebasp_gender+'</td>'+
                                '<td>'+ebasp_category+'</td>'+
                                '<td>'+office+'</td>'+
                                '<td>'+ebasp_designation+'</td>'+
                                '<td>'+ebasp_date_of_joining+'</td>'+
                                '<td>'+ebasp_grade+'</td>'+
                                '<td>'+ebasp_slab+'</td>'+
                                '<td>'+ebasp_basic+'</td>'+
                                '<td>'+ebasp_created_on+'</td>'+
                                '<td>'+ebasp_created_by+'</td>').appendTo("#search_table");
        });
    },
    cache: false,
});return false;
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求差集那个函数有问题,有无佬可以解决
    • ¥15 MATLAB动图问题
    • ¥15 【提问】基于Invest的水源涵养
    • ¥20 微信网友居然可以通过vx号找到我绑的手机号
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名