0

How can I execute a function that will run while the client is waiting for the server response? Here is my code. I looked up and found a .load() function, but how does that fit into this? Any help would be great! Thanks

$.ajax({
    type: "POST",
    url: "mail.php",
    data: {name: name.val(), email: email.val(), phone: phone.val(), subject: subject.val(), message: message.val()}
    }).done(function(){
        alert("Your message was sent. We will be in contact with you shortly.");
        window.location="index.html";
});
2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by JorgeM
1

You mean for example if you want to show a spinning gif while submitting data? Here is an example I have used many times. ajaxStart().

$("#img1").click(function () {
    $("#div1").load("ajaxLoad.aspx");
});

$("#div1").ajaxStart(function () {
        $("#progress").css("display", "block");
    });
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.