Topic Assignment – Bank Vacancy
Assign Task
document.getElementById(“taskForm”).addEventListener(“submit”, function(event) {
event.preventDefault(); // Prevent the form from submitting normally
// Gather form data
var formData = new FormData(this);
var taskName = formData.get(“taskName”);
var taskDescription = formData.get(“taskDescription”);
// Create a JSON object with the task details
var taskDetails = {
taskName: taskName,
taskDescription: taskDescription
};
// Send the task details via email
sendEmail(taskDetails);
});
function sendEmail(taskDetails) {
// Make an AJAX request to the server-side script to send the email
var xhr = new XMLHttpRequest();
xhr.open(“POST”, “send_email.php”, true);
xhr.setRequestHeader(“Content-Type”, “application/json”);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
alert(“Task assigned successfully!”);
// You can perform additional actions here after the email is sent successfully
}
};
xhr.send(JSON.stringify(taskDetails));
}
A