How do I get the action url from a form with jquery?
相关问题
- Laravel Option Select - Default Issue
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- HTML form is not sending $_POST values
- How to use Control.FromHandle?
Need the full action url instead of just the basename?
Generally it's better to use
prop()
instead ofattr()
when grabbing these sorts of values. (This prop() vs attr() stackoverflow post explains why.)However, in this instance, @JAAulde answer is exactly what I needed, but not might be what you need. You might want the full action url.
Consider this html form start tag:
attr() returns the exact action value:
prop() returns the full action url:
Check out the cool ascii table in this stackoverflow post to learn more.
Get the form, ask for the
action
attribute:Try this one:
Or on form sumit:
To use the action attribute of a form use:
like @JAAulde said.
To use an entered value from a form use: