开发者

JQuery - Fadein an ajaxForm() page call

I have this script that opens a new page inside a span:

开发者_如何学JAVA$(document).ready( function() {
            $('#botao').click( function() {
                $('#pesquisar').ajaxForm({
                    type: 'POST', 
                    target: '#resultado'
                });
            });
        });

I want the new page to fadein, i have tried putting fadein() around with no luck. How do i do that?


I think the beforeSubmit and success callbacks should get there. Something like this:

$('#pesquisar').ajaxForm({
    type: 'POST', 
    target: '#resultado',
    beforeSubmit: function() { $('#resultado').css('display', 'none'); },
    success: function() { $('#resultado').fadeIn(); }
});

The beforeSubmit callback is called right before the form is submitted and hides #resultado in preparation for the fadeIn. Then ajaxForm should put the response in #resultado and call the success callback; the success callback does the fadeIn.

I don't have a handy ajaxForm setup so I can't test this but I'm pretty sure that the above will work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜