Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery and PHP email form not running success function
    primarykey
    data
    text
    <p>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!</p> <p>Here's my jQuery:</p> <pre><code>$.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; } }) </code></pre> <p>and here's my php </p> <pre><code>&lt;?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" ); } ?&gt; </code></pre> <p>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: </p> <p><code>.ajax().done(function{})</code> 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!!! :/</p> <p>Your's frustratedly, Simon.</p> <p>EDIT: Form:</p> <pre><code> &lt;form name="contact"&gt; Email: &lt;input name="email" type="text" id="email" &gt;&lt;br&gt; Message:&lt;br&gt; &lt;textarea name="message" rows="20" cols="246" id="mailContent"&gt;&lt;/textarea&gt;&lt;br&gt; &lt;input class="button" value=""&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload