send post request using form code example
Example 1: javascript send post request
let data = {element: "barium"};
fetch("/post/data/here", {
method: "POST",
body: JSON.stringify(data)
}).then(res => {
console.log("Request complete! response:", res);
});
window.post = function(url, data) {
return fetch(url, {method: "POST", body: JSON.stringify(data)});
}
post("post/data/here", {element: "osmium"});
Example 2: post form data
@if($errors->any())
<form method="post" action="submitmyform">
{{ csrf_field()}}
<p>
<label>Name</label>
<input type="text" name="name" value="{{ old("name")}}"/>
</p>
<p>
<label>Email</label>
<input type="text" name="email" value="{{ old("email")}}"/>
</p>
<p>
<label>Age</label>
<input type="text" name="age" value="{{ old("age")}}"/>
</p>
<p>
<input type="submit" name="Submit">
</p>
</form>