我无法将此Json发送到另一个PHP页面...我必须将其字符串化吗?我的目标是将电子邮件插入数据库并获取验证消息...如果它已经在数据库中,我应该取回验证消息,并且如果已经在数据库中,则不要将其插入数据库中。 我的表单所在的页面是此页面... Index.php
@ViewChild("parent") private parentRef: ElementRef<HTMLElement>;
public getChildren() {
const parentElement = this.parentRef.nativeElement;
const firstChild = parentElement.children[0];
const firstImage = parentElement.querySelector("img");
...
}
<script type="text/javascript">
$(document).ready(function(){
$("#emailForm").submit(function(event){
event.preventDefault();
var form = $(this);
var emailValue = form.find("#email").val();
var url = form.attr("action");
var posting = $.post( url, { email : emailValue });
posting.done(function( data ){
$("#email_approved_message").empty();
$("#email_approved_message").html(data);
});
});
});
</script>
这是我的petme.php页面,我应该在其中验证电子邮件输入值。我无法从功能ServerValidationMessage取回验证消息,我需要取回该字符串并以id = email_approved_message的形式显示它!
<form id="emailForm" method="POST" action="petme.php">
<input type="email" id="email" name="email" placeholder="Email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-zA-Z]{2,3}$" required>
<br>
<span class="error_form" id="email_error_message"></span>
<span class="approved_form" id="email_approved_message"></span>
<br>
<input type="submit" id="submit" name="submit" value="Pošalji">
</form>
?>