2010-10-22 181 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