of a form then send it to a database.
THIS IS MY JAVASCRIPT CODE.
<form id="frm1" method="POST">
Time: <input type="text" name="Time" id='Time'><br>
Engagements: <input type="text" name="Engagements" id='Engagements'><br><br>
<input type="button" onclick="myFunction();" value="Submit">
</form>
<script>
function myFunction() {
document.getElementById("frm1").submit();
var engagements = document.getElementById("Engagements").value;
var time = document.getElementById("Time").value
// Returns successful data submission message when the entered information is stored in database.
if (time == '' || engagements == '') {
alert("Please Fill All Fields");
} else {
// AJAX code to submit form.
$.ajax({
.....THE PROBLEM IS AT THIS LINE....
method: "POST",
data: {'Time' : time, 'Engagements' : engagements},
url: "./Send.php",
cache: false,
success: function() {
console.log(data)
alert('success');}
});
}
return false;
}
</script>
PLEASE WHAT ARE MY DOING WRONGLY?
What error are you getting?
Обсуждают сегодня