2012-03-25 58 views

回答

1

你可以使用一個加載GIF,而你正在處理數據,一旦你有你的DIV準備使用淡入在動畫中。

//Assuming you have a $.ajax request to submit the form: 

//add the loading gif 
$('#submitform').html('<img src="loading.gif" />'); 

//send your form data 
$.ajax({ 
    url: "process.php", 
    data: { 
     param1: 1, 
     param2: 2, 
     param3: 3 
    }, 
    success: function(data){ 
     //hide the div, assuming the process.php return simple html code to your page update the div content, then add the fade in animation 
     $('#submitform').hide().html(data).fadeIn('slow'); 
    } 
}); 
+0

感謝您的回覆!我將如何實現這個目標div被稱爲* submitform *,它是由jQuery形式的ui更新的? – CJS 2012-03-25 11:10:34

+0

當您提交表單時,向div中添加一個簡單的img元素(加載gif)。當你得到結果時,例如在'$ .ajax'調用的成功方法中,隱藏div,用你從服務器獲得的結果替換img元素,然後在動畫中添加淡入淡出。 – slash197 2012-03-25 11:15:31

+1

我不是100%確定代碼的位置,你可以給我示例嗎? – CJS 2012-03-25 11:23:28