SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Nov 2006
    0 Post(s)
    0 Thread(s)

    Question Alternate submit?

    I am making a ajax form request and I am clueless on how to make an alternate submit when javascript is disabled. This is so it works without javascript and uses a separate php file.
    Will someone please help me out and point out how dumb I am.

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Sydney, NSW, Australia
    25 Post(s)
    1 Thread(s)
    You could put a submit button between <noscript> tags so that it only shows when Javascript is not available.

    The action= attribute on the form tag should contain the processing to be performed when Javascript is disabled and the onsubmit action should do what is required for submitting the form when Javascript is enabled and then return false to stop the sction being performed.
    Stephen J Chapman, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Addict
    Join Date
    Oct 2006
    0 Post(s)
    0 Thread(s)
    When JavaScript is disabled and Ajax won't work, you need to fall back to a normal form submit. I design my input pages with a form that contains the input fields. The Form element includes the following attribute:
    onSubmit="return ajaxFormSubmit()"
    Remember that even though JavaScript is enabled, the browser version might not support the XMLHttpRequest object. If the Ajax transmission is successful, the ajaxFormSubmit function returns False - which prevents the normal form submission. If the Ajax transmission fails, the function returns True and the form is submitted normally. Also if JavaScript is turned off the form will submit normally.

    Hope this helps...


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts