Classic ASP, ASP.NET, PHP or any other dynamc language, its all the same as what you're really doing is FORM POST ing, and that's HTML, not actually ASP.
Assuming that you have a form like
<form id="frm-submit" action="/SendEmail.asp" action="POST">
...
<input type="submit" value="Submit form" />
</form>
add a little jQuery to the page as
$(function() {
$("#frm-send").submit(function() {
var data = $(this).serialize(),
action = $(this).attr("action"),
method = $(this).attr("method");
$(".loading").show(); // show loading div
$.ajax({
url: action,
type: method,
data: data,
success: function(data) {
// all went well...
},
error: function(err) {
// there was something not right...
},
complete: function() {
$(".loading").hide(); // hide the loading
}
});
return false; // don't let the form be submitted
});
});
and you're ready to go.
in your sendMail.asp
page, everything you send to Response.Write
will be in the data
variable of the success
method, so after you send the email you have:
Response.Write("done")
Responde.Flush()
Response.End()
in the javascript part, you can handle it like:
success(data) {
if(data === "done")
{
// Super duper! let's show the user a Thank you for submit page
document.location = "/ThankYou.asp";
}
}