Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Perhaps it's because you don't change the http header code of your response and don't specify your data type response.</p> <p>You're php code response to front (jQuery) code with a "200 – OK" status in any case, but you expect an error in some case with an 'HTTP/1.0 400 – Bad Request' response Or a 'HTTP/1.0 500 Internal Server Error'.</p> <p>And, like say Eggplant, you have to specify your response data type as 'Content-Type: application/json'.</p> <p>So, the final code would be something like this :</p> <pre><code>&lt;?php ... header('HTTP/1.0 204 – No Content', true, 204); header('Content-Type: application/json'); if ( empty($myname) || empty($myemail) || empty($mymessage) ) { header('HTTP/1.0 400 – Bad Request', true, 400); exit('{"error":"That value was invalid!"}') } else { ... $send = mail( $toemail, $subject, $body, "From: $email" ); if (!$send) header('HTTP/1.0 500 – Internal Server Error', true, 500); exit ('{"error":"Mail could not be sent."}'); } } return; ?&gt; </code></pre> <p>For the Warning <code>Cannot modify header information - headers already sent by (output started at /homepages/.../design/contact.php:1)</code> you can examine <a href="https://stackoverflow.com/questions/8028957/headers-already-sent-by-php">this answer</a> on the same problem.</p> <p>Output can be:</p> <ul> <li>Unintentional: <ul> <li>Whitespace before </li> <li>UTF-8 Byte Order Mark</li> <li>Previous error messages or notices</li> </ul></li> <li>Intentional: <ul> <li>print, echo and other functions producing output (like var_dump)</li> <li>Raw areas before </ul></li> </ul> <p><strong>Update after chat session : it's was a UTF-8 BOM problem</strong></p>
 

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