Checkout this HTML using the attribute action
, method
and target
from <form></form>
tag:
<form action="/action_page.php" method="get" target="_blank">
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br><br>
<button type="submit"></button>
</form>
Is a good practice using form tag's atributes in HTML? It will redirect the user to another page. Isn't a better option always using XHR Requests?
JavaScript XHR example in JQuery with previous HTML code:
$("button").click(function(e){
e.preventDefault();
$.post("demo_test_post.asp",
{
name: $("[name='fname']")
},
function(data,status){
});
});