title: To return status and data to html in PHP
body: <p>I am trying to get the result of mail() from PHP to jquery using post(). How can I set post() in JQuery and send the status of the mail in PHP?</p>
  
  <p>In .php</p>
  
  <pre><code>$status = mail($to, $subject, $msg, $headers);
  if ($status) {
      http_response_code(200);
      echo 'Mail sent!';
  } else {
      http_response_code(500);    
      echo 'Something went wrong!';
  }
  </code></pre>
  
  <p>In JQuery, </p>
  
  <pre><code>$.post('test.php', data, function(data) {
    alert('data: ' + data);
  })
  </code></pre>
  
  <p>Should I have to return data from php?</p>