ajax多次调用同一个文件

时间:2014-10-24 09:23:18

标签: php jquery ajax

我通过点击按钮使用ajax加载页面。在里面我点击另一个按钮调用另一个ajax文件。但问题是,如果我单击第一个按钮2次,然后单击第二个按钮调用第二个文件2次。如果3然后3次等等。

第一个电话的代码是:

        $(document).on("click",".ajaxmenu a, .dropdown a",function(){
                var link_name = $(this).attr('id');
                if(link_name == 'not_this'){return false;}                  
                $('#main-content').html('<div style="margin:10% 0% 0% 35%"><img src="media/loading.gif" ></img></div>');
                var a = this.hash.substr(1);
                $.get( "first.php",{ patient_id : link_name },function( data ) {
                  $('#main-content').html(data).hide().fadeIn(1000);
                });
    });

第二个电话的代码是:

        $(document).on('click','#cb',function(){
                var test_number = $('#test_number').val();  
                var more_d1 = $('#d1').val();
                var more_d2 = $('#d2').val();
                $.get( "functions/reports_more_content.php",{ tn : test_number, date1 : more_d1, date2 : more_d2} ,function(more_data) {
                    if(more_data == 'asd'){
                        $('#no-more').append("There are no more content to show");
                        $('#cb').remove();
                    }else
                    {
                    $('#next_id').remove(); 
                    $('.more_content').append(more_data);
                    }
                });     
    }); 

0 个答案:

没有答案