How to set a Header field on POST a form?

前端 未结 8 1907
情书的邮戳
情书的邮戳 2020-11-27 04:08

How can I set a custom field in POST header on submit a form?

8条回答
  •  天涯浪人
    2020-11-27 04:51

    From FormData documention:

    XMLHttpRequest Level 2 adds support for the new FormData interface. FormData objects provide a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest send() method.

    With an XMLHttpRequest you can set the custom headers and then do the POST.

提交回复
热议问题