Can a html button perform a POST request?

后端 未结 4 1074
庸人自扰
庸人自扰 2020-12-12 19:44

I want a submit type button to send a POST request.

I am thinking about something like this:

4条回答
  •  悲&欢浪女
    2020-12-12 20:00

    You can:

    • Either, use an , instead of that button.
    • or, Use a bit of javascript, to get a hold of form object (using name or id), and call submit(..) on it. Eg: form.submit(). Attach this code to the button click event. This will serialise the form parameters and execute a GET or POST request as specified in the form's method attribute.

提交回复
热议问题