How to do two POST requests for visitors with JS disabled on one submit button?

前端 未结 4 1136
醉话见心
醉话见心 2021-01-15 08:12

I got help with solving a problem in this thead: Redirect with POST data. Now that I decided that the whole site and even this function must work when JS is disabled I need

4条回答
  •  生来不讨喜
    2021-01-15 08:39

    The reason they initially suggested AJAX is for user experience, and is not a requirement for a form to be able to post. You will need to either present the user with a separate step to choose a form or have the same page reload or load another page.

    Some pseudocode for example:

    Your form_selection() routine should draw a form which has a select, checkbox, radio button or whatever that will POST a string or integer (for the switch) back to the script you are running from.

    When the page reloads it will call the correct display_form() based on the value it passed to itself. These functions will set up the form for whatever you want to post to the gateway.

    I have read elsewhere on this site that using for your form action is not a good idea, and you should rather manually type your script name in.

提交回复
热议问题