In the
results column, there is an arra (3) on the left side of
, and there is a number 2 in front of it. Does that indicate that the result has been output twice? The test.html:22 also appears twice on the right side of
. Excuse me, how do you explain this?
html is very simple
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<form id="myForm" action="test.php" method="post">
<input type="text" name="name">
<input type="password" name="psw">
<input type="text" name="test" value="check">
<input type="button" id="submit" value="">
</form>
<script>
function sendData(){
console.log("haha");
var form = document.getElementById("myForm");
var formData = new FormData(form);
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("post", "test.php",true);
xmlHttp.send(formData);
xmlHttp.onreadystatechange = function(){ console.log(xmlHttp.responseText)};
}
ob = document.getElementById("submit");
ob.addEventListener("click",sendData);
</script>
</form>
</body>
</html>
php is simpler
php
var_dump ($_ POST);
? >