0

使用 jQuery 表单插件时,淡出表单和淡入结果的最佳方法是什么?(http://jquery.malsup.com/form/#getting-started)

<script type="text/javascript">

// prepare the form when the DOM is ready 

$(document).ready(function() { 
var options = { 
    target:        '#t5',  
    beforeSubmit:  showRequest,  
    success:       showResponse   
}; 

// bind to the form's submit event 

$('#t5_booking').submit(function() { 
    $(this).ajaxSubmit(options); 
    return false; 
    }); 
});  

// pre-submit callback 

function showRequest(formData, jqForm, options) { 
    var queryString = $.param(formData); 
    // alert('About to submit: \n\n' + queryString); 
}

// post-submit callback 

function showResponse(responseText, statusText, xhr, $form)  { 
} 
</script>
4

1 回答 1

2

你可以使用这样的回调函数:

function showResponse(responseText, statusText, xhr, $form)  {
    $($form).fadeOut('slow', function(){ // or maybe $form.fadeOut('slow', function(){
        // show your result with fadeIn func
        $('#resultdiv').html(responseText).fadeIn('fast');
    });
}

你也可以在fadeIn中使用回调

于 2012-03-26T10:28:39.850 回答