加载直到Ajax加载

时间:2015-02-07 16:00:09

标签: jquery ajax wordpress

我有div到index.php(wordpress)。 使用jquery将数字发送到page.php,并将带有ajax的结果返回到index.php

我希望显示加载Div(或文本或图像)直到加载Ajax。

我的代码:

<script>
myfunc = function()
{           
    $("#target").slideUp(400);
    $("#target").slideDown(400,"swing",function()
        {                           
            splittedURL=window.location.href.split("#");
            $.post('<?php bloginfo('template_directory'); ?>/page.php','state='+splittedURL[1],function(data,status)
            {
                $("#target").html(data);
            })      
        }
    );                          
}
</script>

1 个答案:

答案 0 :(得分:0)

<script>
myfunc = function()
{   
    $('#target').html("my html here");
    $("#target").slideUp(400);
    $("#target").slideDown(400,"swing",function()
        {                           
            splittedURL=window.location.href.split("#");
            $.post('<?php bloginfo('template_directory'); ?>/page.php','state='+splittedURL[1],function(data,status)
            {
                $("#target").html(data);
            })      
        }
    );                          
}
</script>