11
rated 0 times
[
13]
[
2]
/ answers: 1 / hits: 20056
/ 8 Years ago, thu, february 11, 2016, 12:00:00
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??
More From » php