DIR : /home/kozerus/public_html/formdata.html

/home/kozerus/public_html

<html>
<head>
	<title>formdata.html 20200830_0133</title>



	<script id="script_sendform" >
function sendForm() {
  var formData = new FormData();
  formData.append('username', 'johndoe');
  formData.append('id', 123456);

  var xhr = new XMLHttpRequest();
//  xhr.open('POST', '/server', true);
xhr.open('POST', '/jax.php', true);
  xhr.onload = function(e) { ... };

  xhr.send(formData);
}
	</script>

	</head>

<body bgcolor=linen>
	<h1>formdata</h1>

<!-- <form id="myform" name="myform" action="/server"> -->
<form id="myform" name="myform" action="/jax.php">
  <input type="text" name="username" value="johndoe">
  <input type="number" name="id" value="123456">
  <input type="submit" onclick="return sendForm(this.form);">
</form>

<script id="script_" >
function sendForm(form) {
  var formData = new FormData(form);

  formData.append('secret_token', '1234567890'); // Append extra data before send.

  var xhr = new XMLHttpRequest();
  xhr.open('POST', form.action, true);
  xhr.onload = function(e) { ... };

  xhr.send(formData);

  return false; // Prevent page from submitting.
}


	</script>


	<script id="script_fileload" >
function uploadFiles(url, files) {
  var formData = new FormData();

  for (var i = 0, file; file = files[i]; ++i) {
    formData.append(file.name, file);
  }

  var xhr = new XMLHttpRequest();
  xhr.open('POST', url, true);
  xhr.onload = function(e) { ... };

  xhr.send(formData);  // multipart/form-data
}

		document.querySelector('input[type="file"]').addEventListener('change', function(e) {
			uploadFiles('/jax.php', this.files);
}, false);


		</script>




	</body>
	</html>
//


koh5_pano



Your browser does not support the HTML5 canvas element.


Drag mouse to navigate.

Navigation





17.Aug.2010, Martin Wengenmayer