Send email on html button click
<p>I want to send an email as soon as I click on html button. To do this task, I've written following code</p>

<p><strong>HTML code:</strong></p>

<pre><code>&lt;button onclick="sendEmail()"&gt;Send Email&lt;/button&gt;
&lt;p id="mailStatus"&gt;&lt;/p&gt;
</code></pre>

<p><strong>Java Script Code:</strong></p>

<pre><code>function sendEmail()
{
     $.ajax({
           url: "mail.php",
           type: "POST",
           success: function(response) {
               if (!response) {
                    alert("Something went wrong. Please try again");
                    return;
               }

               var parsedJSON = eval('('+response+')');

               // If there's an error, display it.
               if(parsedJSON.Error) {
                  // Handle session timeout.
                  if (parsedJSON.Error == "Timeout") {
                       alert("Session timed out. Please login again.");
                       window.location.reload();
                   }
                }
               document.getElementById('mailStatus').innerHTML = "Email Sent successfully";  
            }
     });
}
</code></pre>

<p>The problem if when I click on Send Email button, I get an error message as </p>

<p><code>"Uncaught ReferenceError: $ is not defined"</code></p>

<p>Can someone please help??</p>