How do I add a redirect to a 'thank you' page (thankyou.html) after form submission in this.js code. Currently it apends a message.
$.ajax({ url: "././mail/contact_me.php", type: "POST", data: { name: name, phone: phone, email: email, message: message }, cache: false, success: function() { // Enable button & show success message $("#btnSubmit").attr("disabled", false); $('#success').html("<div class='alert alert-success'>"); $('#success >.alert-success').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×").append("</button>"); $('#success >.alert-success').append("<strong>Thank You. Your message has been sent; </strong>"). $('#success >.alert-success');append('</div>');
You can do this simply by adding window.location = "thankyou.html";
like this:
$.ajax({
url: "././mail/contact_me.php",
type: "POST",
data: {
name: name,
phone: phone,
email: email,
message: message
},
cache: false,
success: function() {
// Enable button & show success message
$("#btnSubmit").attr("disabled", false);
$('#success').html("<div class='alert alert-success'>");
$('#success > .alert-success').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×")
.append("</button>");
$('#success > .alert-success')
.append("<strong>Thank You! Your message has been sent. </strong>");
$('#success > .alert-success')
.append('</div>');
// Add it here
window.location = "thankyou.html";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.