0
我想使用XMLHttpRequest來獲取遠程PHP文件的響應並將其顯示在我的頁面上。通過XMLHttpRequest提交表單
我的問題當然是:表單的數據沒有被提交到遠程PHP頁面。
我該如何做到這一點? 謝謝。
<form name="creation" action="" method="post">
E-mail:
<input required type="text" name="emailCreation" onchange="emailValidate();"
onkeypress="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();">
<span id="emailRegexJavascriptResponse"></span>
<br>
Username: <input required type="text" name="userCreation" onchange="userValidate();"
onkeypress="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();">
<span id="userRegexJavascriptResponse"></span>
<br>
Password: <input required type="text" name="passwordCreation" onchange="passwordValidate();"
onkeypress="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();">
<span id="passwordJavascriptResponse"></span>
<br>
<input type="button" value="Submit" onclick="creationResult();">
<div id="here"></div><div id="here2"></div>
<!-- End -->
<script type="text/javascript">
function creationResult() {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("here").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","accountcreation.php",true);
xmlhttp.send();
}