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 8957701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:03:10+00:00 2026-06-15T15:03:10+00:00

Hi there I’m trying to create a simple enough php email form without any

  • 0

Hi there I’m trying to create a simple enough php email form without any need for page refreshing using the jQuery .ajax() method, however I want all the fields to reset once the email has been sent and at the moment this isn’t happening for some reason!

Here’s my jQuery:

$.ajax({
    url:"http://www.mysite.co.uk/contactMe.php",
    data: {'email': email,'content': content},
    success: function(response){
        $("#mailContent").css({ 'box-shadow': ''}); 
            $("#email").css({'box-shadow': ''});    
            $("#email").val('');
            $("#mailContent").val('');
            alert("DONE");

        return false;
        }
})

and here’s my php

<?php 

function spamcheck($field)
  {
  //filter_var() sanitizes the e-mail
  //address using FILTER_SANITIZE_EMAIL
  $field=filter_var($field, FILTER_SANITIZE_EMAIL);

  //filter_var() validates the e-mail
  //address using FILTER_VALIDATE_EMAIL
  if(filter_var($field, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
  else
    {
    return FALSE;
    }
  }

$email = $_GET['email'];
$content = $_GET['content'];

$mailcheck = spamcheck($email);
  if ($mailcheck==FALSE)
    {

    }
  else
    {//send email
    mail("myemail@googlemail.com", "Subject: Website Contact Form",
    $content, "From: $email" );
    }

?> 

Please note I’ve changed the url address and the email address for privacy, the email is sending fine as I receive it in my inbox. I’ve also tried the same thing using:

.ajax().done(function{}) and there’s no luck with that either, The worst thing is this works fine on another website I’ve used it on when I use .ajax() to create a commenting system, but it refuses to work at all on this site!!! :/

Your’s frustratedly, Simon.

EDIT: Form:

    <form name="contact"> Email: <input name="email" type="text" id="email" ><br>
Message:<br> <textarea name="message" rows="20" cols="246" id="mailContent"></textarea><br> 
<input class="button" value=""> </form>
  • 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-15T15:03:12+00:00Added an answer on June 15, 2026 at 3:03 pm

    You cannot use ajax to POST cross-domain (read up on CORS for specifics); for security reasons the browser blocks that as it might take you (and your data) to shady sites without you noticing it.

    If the script you are posting is on the same server, you should remove the domain name and use a path relative to the root of the web-site:

    url:"/contactMe.php"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

there's a php scripts which create multiple <p>text</p> elements due to user's query. I'd
There is a moment in my app, that I need to force to show
There's a Rails 3.2.3 web application which doesn't use any database. But in spite
There is any way to set the generic type (T) of class in the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
There is a div (form) which opens on the click of a button. There
There doesn't seem to be any tried and true set of best practices to
There are a TextField , a ListBox and a TextArea inside my Form .
There is a component that I have been using since IE7 and had never
There are 2 different article types: post(blog) and page in Octopress. What if I

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.