如何在ajax页面完全加载后调用函数

时间:2011-06-23 17:26:00

标签: ajax function complete

使用jquery,我加载了

enrollment_forms.php
  • 页面进入一个名为 - ( container_level2 )的div。

  • container_level2

  • 中注册的enrollment_forms.php页面时
  • 我想调用另一个函数。

.....我怎么能用一个带参数的函数来做到这一点。

这是我做过的一个功能。

function view_update_load_form(list_index, student_id){
     $.ajax({
            url: "enrollment_forms.php",
            success: function(result){
                $('#container_level2').html(result);
            },
            complete: function(){
                load_form(list_index, student_id);
            }
            }); 


}       

在上面的代码中...我用两个参数调用函数 - 有两个参数。

view_update_load_form(list_index, student_id)...

此功能加载页面。

enrollment_forms.php.

加载enrollment.forms.php时。我想打电话给第二个功能

load_form(list_index, student_id).

有相同的参数..

我怎么能......这不起作用...... 它经常调用第二个功能,即使页面没有完成加载..我该怎么做..

2 个答案:

答案 0 :(得分:2)

使用

ajaxComplete();

有关更多信息,请参阅以下链接 JQuery ajaxComplete

答案 1 :(得分:1)

您可以将load_form电话放入success功能:

success: function(result){
    $('#container_level2').html(result);
    load_form(list_index, student_id);
},

这样在插入html之前就不会调用它。

相关问题