Ajax content and jQuery animation erfects

后端 未结 3 352
粉色の甜心
粉色の甜心 2021-01-27 21:25

I\'m trying to make Ajax content for WordPress posts to appear using jQuery animation effects, the problem is that the first animation - in this case \"fadeOut\" works OK but th

3条回答
  •  不要未来只要你来
    2021-01-27 22:15

    Here is an complete example:
    - HTML

    
            // Your static content
        
            // Your AJAX loaded content
        

    - JS

    $(document).ready(function()
    {
        function ajax_request() {
            $.ajax({ 
                //ajax request
            });
        }
    
        // for when the page first loads
        ajax_request();
    
        $('#your_trigger').change(function()
        {
            $('table tbody').hide('fast',load_content);
            $('#load').remove();
            $('table tbody').append('LOADING...');
            $('#load').fadeIn('fast');
    
            function load_content() {
                ajax_request();
                show_new_content();
            }
            function show_new_content() {
                $('table tbody').show('fast',hideLoader());
            }
            function hide_loader() {
                $('#load').fadeOut('fast');
            }
    
        });
    
    });
    

提交回复
热议问题