2010-10-22 179 views
0

我有一個使用jQTools覆蓋和jQuery .ajax提交例程的窗體。一旦顯示成功/錯誤消息,我希望疊加層關閉。我如何將納入一個setTimeout的這個(成功/錯誤味精已經顯示後,才)覆蓋的ID是「#overlayForm」jQuery setTimeout覆蓋提交

$.ajax({ 
     type: $(form).attr('method'), 
     url: form.action, 
     data: dataString, 
     clearForm: true, 
     success: function (data) { 
      if (data == "Mail sent") { 
       $("#formWrap, #supportHdln").hide(); 
       $("#thankYou").html('<h2><span>Thank You | </span>We have received your request.</h2><p>A Customer Service Representative from Kinetick will contact you shortly</p>').fadeIn("slow"); 

      } else { 
       $("#formWrap, #supportHdln").hide(); 
       $("#error").html('<h2"><span>Uh Oh | </span>We have encountered an error in your submission.</h2><p> Please check that all required form fields were filled out, if that does not resolve the issue, please <a href="mailto:[email protected]?subject=Cancelling Kinetick Account Help">email</a> us here.</p>').fadeIn("slow"); 
      } 
     } 
    }); 
    return false; 
} 

回答

1

我想最簡單的事情是一個匿名函數:

setTimeout(function(){$("#overlayForm").hide();},1000); 

我已經看過jQuery的工具的文檔,我想你一定要講這一點:

http://flowplayer.org/tools/overlay/index.html

他們談論「C失去()」。

那麼這將是:

$("#overlayForm").close(); 
+0

我已經編輯我的答案正是 – netadictos 2010-10-22 17:07:43

+0

感謝我需要的東西!我可以將貼近的按鈕應用於疊加層中的一個按鈕,但該功能將爲我執行此操作,並且我可以刪除關閉按鈕! – 2010-10-22 18:24:44

+0

經過一番測試,以上只是使內容消失。我可以在疊加調用本身中添加一個「onLoad」函數,但是從顯示錶單的時候就會觸發,我需要它在提交表單時啓動定時器。有任何想法嗎? – 2010-10-22 18:56:33