views:

26

answers:

1

I have a form that uses a jQTools overlay and jQuery .ajax submission routine. I would like the overlay to close once the success/error message has been displayed. How would I incorporate a setTimeout into this (only after success/error msg has been displayed) the ID of the overlay is "#overlayForm"

    $.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;
}
A: 

The simplest thing I suppose is an anonymous function:

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

I have looked at the documentation of Jquery Tools, I think you must talk about this:

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

They talk about "close()".

Then it would be:

$("#overlayForm").close();
netadictos
I have edited my answer
netadictos
@netadictos - thanks exactly what I needed! I can apply the close to a button within the overlay, but the function will do it for me and I can remove the close button!
Dirty Bird Design
@netadictos - after some testing the above only made the content go away. I was able to add a "onLoad" function in the overlay call itself, but it fires from the time the form is displayed, i need it to start the timer on submit of the form. any ideas?
Dirty Bird Design
I am not quite sure as I know few details. I suppose you put my code inside the success function. It should work if it does in the onload event.
netadictos