有人可以帮我有关我的Ajax和jQuery吗?我的问题是我需要单击两次以执行我的代码。我将查看和保存的PHP代码分开。我不知道为什么会发生这种情况,但我的位置有问题吗?始终显示此错误“无法在'DOMWindow'上执行'postMessage':提供的目标原点('https://www.ciuvo.com')与收件人窗口的原点('null')不匹配”。我是Ajax和jQuery的新手,所以我真的需要您的帮助。如果您想查看我的PHP代码,我会提供。
$(document).ready(function(){
$("#btnViewss").click(function(){
$.ajax({
url: "viewFuneral.php",
method: "post",
data: {btnViewss: ""},
success: function(data){
document.write(data);
}
});
});
$("#btnSavess").click(function(){
$.ajax({
url:"insert.php",
method:"post",
data:{btnSavess: "", firstName: $("#firstName").val(), middleName: $("#middleName").val(),
lastName: $("#lastName").val(), dob: $("#dob").val(), dod: $("#dod").val(), civilStatus: $("#txtStatus").val(),
address: $("#txtAddress").val(), nameOfFather: $("#nameOfFather").val(), nameOfMother: $("#nameOfMother").val(), reservationDate: $("#reservationDate").val(),
selectTime: $("#selectTime").val(),},
success: function(data){
alert(data);
}
});
});
});
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery/jquery.js"></script>
<script type="text/javascript" src="javascript/funeral.js"></script>
<link rel="stylesheet" type="text/css" href="style.css?v=<?php echo time(); ?>">
<title>Parish - Funeral</title>
</head>
<body>
<main>
<a href="#">
<h2 class="section-heading">Funeral</h2>
</a>
<form id="simpleForm">
<div class="div-container">
<label>Firstname :</label>
<input type="text" id="firstName" name="firstName" placeholder="Enter First Name">
</div>
<div>
<label>Middlename :</label>
<input type="text" id="middleName" name="middleName" placeholder="Enter Middle Name">
</div>
<div>
<label>Lastname :</label>
<input type="text" id="lastName" name="lastName" placeholder="Enter Last Name">
</div>
<div>
<label>Date of Birth :</label>
<input type="date" id="dob" name="dob">
</div>
<div>
<label>Date of Death :</label>
<input type="date" id="dod" name="dod">
</div>
<div>
<label>Civil Status :</label>
<input type="input" id="txtStatus" name="civilStatus" placeholder="Enter Civil Status">
</div>
<div>
<label>Address :</label>
<input type="input" id="txtAddress" name="address" placeholder="Enter Address">
</div>
<div>
<label>Name of Father :</label>
<input type="input" id="nameOfFather" name="nameOfFather" placeholder="Enter Father Name">
</div>
<div>
<label>Name of Mother :</label>
<input type="input" id="nameOfMother" name="nameOfMother" placeholder="Enter Mother Name">
</div>
<div>
<label>Reservation Date :</label>
<input type="date" id="reservationDate" name="reservationDate">
</div>
<div>
<label>Select Time :</label>
<input type="time" id="selectTime" name="selectTime">
</div>
<div id="btnSubmit"><br><br>
<button id="btnSavess">Save</button>
<button id="btnViewss">View</button>
<!-- <a href="reservation.php"><button type="button">Back</button></a> -->
</div>
</form><br><br>
</main>
</body>
</html>