Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery.post not receiving errors from php script
    primarykey
    data
    text
    <p>I know this has been asked before and I have looked at every post I could find that deals with this. I still cannot get the jQuery.post function to correctly receive the error from a php script. Here are both. <br>PHP:</p> <pre><code>&lt;?php ##CONFIGURATION # LIST EMAIL ADDRESS $toemail = "email here"; # SUBJECT (Subscribe/Remove) $subject = "Someone has contacted International Designs"; # RESULT PAGE $location = "../thank-you.php"; ## FORM VALUES ## $myname = $_REQUEST['myname']; $myemail = $_REQUEST['myemail']; $mymessage = $_REQUEST['mymessage']; if ( empty($myname) || empty($myemail) || empty($mymessage) ) { exit('{"error":"That value was invalid!"}') } else { # SENDER $email = $myname . " &lt;" . $myemail . "&gt;"; # MAIL BODY $body .= "Name: " . $myname . " \n\n"; $body .= "Email: " . $myemail . " \n\n"; $body .= "Message: " . $mymessage . " \n\n"; # add more fields here if required ## SEND MESSGAE ## mail( $toemail, $subject, $body, "From: $email" ) or die ("Mail could not be sent."); } ?&gt; </code></pre> <p>JS:</p> <pre><code>if (verify(myname, myemail, mymessage, human, hash, patt)) { $.post(myform.attr('action'), myform.serialize(), function() { $('#email-success').fadeIn(); myform[0].reset(); setTimeout("$('#email-success').fadeOut();", 5000); }, 'json') .fail(function() { alert('An error has occurred. Please try again later.') }); } </code></pre> <p>I have tried about 5 different methods already, none of which have worked. When I put 'json' as the datatype in the .post function the .fail <em>always</em> fires, no matter what's in the php script. If I leave datatype out, then .fail <em>never</em> fires under any circumstance. I have a feeling the problem is with the php commands and datatype. Any help is appreciated.</p>
    singulars
    1. This table or related slice is empty.
    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