Answers for "button post request javascript"

9

send post request form javascript

let data = {element: "barium"};

fetch("/post/data/here", {
  method: "POST", 
  body: JSON.stringify(data)
}).then(res => {
  console.log("Request complete! response:", res);
});


// If you are as lazy as me (or just prefer a shortcut/helper):

window.post = function(url, data) {
  return fetch(url, {method: "POST", body: JSON.stringify(data)});
}

// ...

post("post/data/here", {element: "osmium"});
Posted by: Guest on March-04-2020
0

html button send post request

<form method='POST' action='myFile.php'>
  <input name='myInput'>
  <button type='submit'>Submit</button> 
  <!--Sends input value to the page set as 'action' parameter. 
	For example a php file.-->
</form>
Posted by: Guest on May-23-2021

Code answers related to "button post request javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language