Skip to content

Instantly share code, notes, and snippets.

@wozozo
Created June 24, 2015 15:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wozozo/f2140f2f33bf2c3f6e3a to your computer and use it in GitHub Desktop.
Save wozozo/f2140f2f33bf2c3f6e3a to your computer and use it in GitHub Desktop.
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
error_log(var_export($_SERVER, true));
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<form id="test" enctype="multitype/formdata">
<input type="text" name="xxx" />
<input type="submit" />
</form>
<script type="text/javascript">
(function(f) {
f.addEventListener('submit', function (e) {
e.preventDefault();
var fd = new FormData();
fd.append("test", "test");
var r = new XMLHttpRequest();
r.open("POST", "/", true);
r.addEventListener('readystatechange', function () {
console.log('hoge');
}, false);
r.send(fd);
console.log("send");
}, false);
})(document.getElementById('test'));
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment