Easier way to transform FormData into query string

前端 未结 3 1208
渐次进展
渐次进展 2021-02-02 09:26

I’m sending a POST request via XMLHttpRequest with data entered into an HTML form. The form without interference of JavaScript would submit its data encoded as

3条回答
  •  灰色年华
    2021-02-02 09:44

    You could use URLSearchParams

    const queryString = new URLSearchParams(new FormData(myForm)).toString()
    

提交回复
热议问题