I want to send an email as soon as I click on html button. To do this task, I've written following code
HTML code:
<button onclick="sendEmail()">Send Email</button>
<p id="mailStatus"></p>
Java Script 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";
}
});
}
The problem if when I click on Send Email button, I get an error message as
"Uncaught ReferenceError: $ is not defined"
Can someone please help??