问题:
I have a basic question. I cannot find an explanation of form action="." despite searching for on google, www.w3schools.com, etc...
Anyone know what the . action means fo...
可以将文章内容翻译成中文,广告屏蔽插件会导致该功能失效:
问题:
I have a basic question. I cannot find an explanation of form action="." despite searching for on google, www.w3schools.com, etc...
Anyone know what the . action means for forms? Is it specific to Django? Bootstrap?
Code below:
{% extends "Blog.html" %}
{% block blog%}
<h1>Create an account</h1>
<p>Please, sign up using the following form:</p>
<form action="." method="post">
{{ user_form.as_p }}
{% csrf_token %}
<p><input type="submit" value="Create my account"></p>
</form>
{% endblock %}
回答1:
Form Action attribute specifies where to send the form-data when a form is submitted
Possible accepted values:
- An absolute URL: points to another web site (like action="http://www.example.com/example.htm")
- A relative URL - points to a file within a web site (like action="example.htm")
in your case of action="."
you are pointing to current url/file/directory. So it will reload the same page on form submission.
回答2:
Normally, the action
attribute in a form specifies where the data should go to, for example a processing file: action="proces.php"
.
Sometimes, action="#"
or action="."
is used to reload the page and process the data on the same page.
Basically, it just submits the form to the same page.
回答3:
It reloads the current page, but with new data.