1

Possible Duplicate:
Is it a good practice to use an empty URL for a HTML form's action attribute? (action=“”)

I'm updating a project to include an Ajax Updater (http://ajaxuploader.com) and couldn't figure out why it wasn't working on my page but worked in my simple example. So I started pulling stuff off the page and found out it was the Action="#" in my form tag.

Unfortunately removing this removes other functionality (think it calls some existing Ajax but not quite sure). What I'm asking is: what is Action="#" and are there any alternatives I could try?

Community
  • 1
  • 1
windowsgm
  • 1,566
  • 4
  • 23
  • 55
  • 1
    I've actually deleted my answer; your question is already answered here: http://stackoverflow.com/questions/1131781/is-it-a-good-practice-to-use-an-empty-url-for-a-html-forms-action-attribute-a - specifically - http://stackoverflow.com/a/10314447/1073107. Note also the side effect of scrolling to the top after the post back has been completed! – dash Jul 27 '12 at 12:09

1 Answers1

4

Action="#" is basically the html equivalent of Post to self. # is technically an anchor so if you click on a link that is just "#" it does nothing.

Browser should interpret any Action="#" as Action="THE_HOSTNAME/PAGE"

Its designed to get around W3C Validation a times since Action="" is considered invalid, since all attributes must have values, this ensures a value is available for the attribute.

John Mitchell
  • 9,653
  • 9
  • 57
  • 91