0

我想按一定顺序执行 3 个函数,我这样做:

function nextPage() {
    var loading_temp = $('#loading_temp');

    loading_temp.show()
        .queue(function() {
            nextPage980()
                .queue(function() {
                    loading_temp.hide();
                    $(this).dequeue();
                });
            $(this).dequeue();
        });         
}

'#loading_temp' 出现,然后函数执行,但最后一个函数(隐藏加载 gif)不执行!

Chrome 给出了这个错误: Uncaught TypeError: Cannot call method 'queue' of undefined

nextPage980() 函数是这样的:

function nextPage980() {
        var ajax_heading = $('#ajax_heading');          
        var cur_heading = $('#cur_heading');            
        var temp_heading = $('.temp_heading');
            var temp_heading_first = temp_heading.filter(':first');         
        var loading_temp = $('#loading_temp');

        var htmlHeader = "Εγκαταστάσεις";           

        ajax_heading.attr('class', 'next_temp');        
        cur_heading.css({'margin-right' : '20px'}).after('<div id="cur_heading" class="temp_heading" data-tempPos="2"><h1 class="page_heading"><span class="heading_span">' + htmlHeader + '</span></h1></div>')        
            .queue(function() {
                ajax_heading.animate({'margin-left' : '-1000px'}, 1000, 'easeInExpo')               
                    .queue(function() {
                        temp_heading_first.remove();                        
                        cur_heading.removeAttr('style');                        
                        ajax_heading.attr('class', 'cur_temp').removeAttr('style');                                                     
                        $(this).dequeue();
                    });
                $(this).dequeue();
            });     
    }

提前致谢!

4

1 回答 1

1

您只需要从nextPage980. 在末尾添加一个无条件return $(this);。就目前而言,您正在调用queue当前的返回值,这没什么(因此您的错误消息)。

于 2012-04-16T11:04:23.997 回答