Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8816533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:38:37+00:00 2026-06-14T04:38:37+00:00

I have several contact forms using the same general AJAX code: $(document).ready(function() { $(‘#mainMail’).submit(

  • 0

I have several contact forms using the same general AJAX code:

$(document).ready(function() {
    $('#mainMail').submit( function() {
        $.ajax({
            type: "POST",

            url : "<?php echo home_url(); ?>/wp-content/themes/retlehs-roots-f45f4f5/assets/bin/process.php",
            data: $(this).serialize(),
            success: function() {
                    $('#enquiryBox #submitSuccess').removeClass('hidden');
                    setTimeout(function() { $("#enquiryBox #submitSuccess").addClass('hidden'); }, 15000);       
                },
            error: function() {
                $('#enquiryBox #submitFail').removeClass('hidden');
                setTimeout(function() { $("#enquiryBox #submitFail").addClass('hidden'); }, 15000);
            }
            });
        return false;
    });
});

In short, when it successfully submits the form and emails me (via process.php) the #submitSuccess div DOES show up as it should. Problem is, when it fails, the div also shows up (the #submitFail div stays hidden).

I’m guessing that this is because the ajax post failure would only occur if the process.php isn’t successfully called? Is there any way to adjust this so that if the email isn’t sent to me via process.php, the user gets an error message?

Here’s my process.php code:

<?php 

$robotest = $_POST['robotest']; //just testin' for robots

$recipient = "info@mydomain.com"; //recipient 
$email = ($_POST['email']); //senders e-mail adress 

if((filter_var($email, FILTER_VALIDATE_EMAIL)) && ($robotest == "")) { 

$Name = ($_POST['name']); //senders name 

$mail_body  = "Hello, \r\n \r\n";
$mail_body .= "You have received a new booking with the following details: \r\n\r\n";
$mail_body .= "{$_POST['comments']}; \r\n \r\n";
$mail_body .= "Please respond to the customer within 30 minutes on the following phone number: {$_POST['phone']} \r\n";
$mail_body .= "Warm regards, \r\n";
$mail_body .= "Robot. \r\n";



$subject = "Free Consult Inquiry"; //subject 
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields 

mail($recipient, $subject, $mail_body, $header); //mail command :) 

} else {
  print "You've entered an invalid email address!";
 }
?>

(the print "you've entered an invalid email address!"was my attempt at an error message, but that’s not working either…)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:38:38+00:00Added an answer on June 14, 2026 at 4:38 am

    You can indicate an error by returning an HTTP error code, e.g.

    } else {
      header("HTTP/1.1 500 Internal error");
      print "You've entered an invalid email address!";
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several contact forms, which all use the same method to to validate
I have several HTML elements (buttons) that fire the same JQuery AJAX request. When
A customer can have several contact. The code below is working but... the contacts
Having a strange issue with the TabContainer in the AJAX Toolkit. We have several
I have several action methods that can use the same view. I've tried calling
I have several models in my project which really should be using identifying relationships,
I have several arrays of dictionaries containing address and contact details. I would like
I have one page website, on homepage(Layout/default.ctp) I have 2 forms, subscribe and contact
I have several tables 1 contacts and multiple data. Contacts has an ID field
I have several xml files with different node structure. I want to extract xml

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.