Why does action="localhost" lead to form not doing anything when submitted?

Sahand
<form id = "myForm" action="localhost" method="get">
    <input name="liftString" type="text">
    <input type="submit">
</form>

This form doesn't do anything when clicking the submit button. I'm not redirected to localhost.

If I change the action attribute to "/localhost" it tries to take me to file:///localhost?liftString=d when running the form locally.

If I change action to "http://localhost", it correctly takes me to http://localhost/?liftString=f.

What is happening in the form example posted? Why does the form do nothing when I click submit?

CLARIFICATION: I understand what's going on when action="/localhost" and action="https://localhost". What I don't understand is why NOTHING happens when I have action="localhost".

Quentin

A URL that doesn't start with a scheme (such as http://) or the scheme-relative indicator (//) is relative to the current URL (unless overridden with <base>.

So the browser takes the URL of the current page, strips off everything after the last / in it, appends the relative URL (localhost) then adds a query string after that.

Since you are using a file:// scheme to view the page, the form would submit to a file on your computer with no HTTP server to process the form data. Since the file localhost doesn't exist, the browser just ignores the form submission request instead.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Why does my formula for date go away when form is submitted?

Form not hitting action in controller when submitted with Ajax

PHP form not doing anything

Why a button is clicked when a form is submitted?

Why i get this AttributeError when form is submitted

Why is the function not implemented when I submitted the form?

Why is CascadeFrom() not doing anything?

Why is this not doing anything?

Why does my form not get submitted when I press the submit button?

Form does not do anything when pressing Submit

Why does this not return anything when searching for a class that is there?

PHP form is displayed but doesn't do anything besides clear itself when submitted

Why "if" is not doing anything in this boolean method?

Why is this form not submitted twice when hitting the button twice?

Why is model's clean run when viewing an already submitted form?

Flask: why isn't AJAX being called when form is submitted?

Why is my form.action different than what gets submitted by the form?

Why does a form not need an 'action' attribute? UserCreationForm

why does razor make form with empty action?

Why form is never submitted with Jquery?

Why is it that this form is being submitted twice?

Why can this form be submitted? (Firefox)

My very simple PHP form not doing anything

Form gives Nulls when submitted

Save Signature when Form is Submitted

Hiding DIV when form is submitted

HTMLCollection is empty when form is submitted

Why when pressing the L key to load back the player rotation it's not doing anything?

Why does my Form Data Value does not correspond to submitted Input Value?