Reputation: 181
I'm having problem to submit form. It simply redirects to 'thank-you' page without sending form data first. Please help, code below:
$(function () {
$("#surveyControl").submit(function(e) {
var companyname = $("#companyname").val();
var firstname = $("#firstname").val();
var lastname = $("#lastname").val();
var dataString = '&companyname='+ companyname + '&firstname='+ firstname + '&lastname='+ lastname;
e.preventDefault();
$.ajax({
type: "POST",
url: "../wp-admin/emailer.php",
data: dataString,
async: false,
success: function (data) {
return true;
}
window.location.href = "thank-you";
})
});
Upvotes: 0
Views: 1958
Reputation: 3393
you need to redirects to 'thank-you' after ajax call success :
$.ajax({
type: "POST",
url: "../wp-admin/emailer.php",
data: dataString,
async: false,
success: function (data) {
window.location.href = "thank-you";
}
Upvotes: 3
Reputation: 9034
window.location.href = "thank-you";
- this is cancelling your ajax request, do this when you got a response from ajax.
Upvotes: 0