FormData does't include the button Javascript

廉价感情. 提交于 2019-11-29 14:46:21

Because you're not actually using the default submit (instead you're doing ajax), you need to add the clicked button yourself. One easy way to do this is to add a hidden input to your form with the name you want the button to have, and then have all the buttons in the form use this click handler:

function clickHandler() {
    this.form.theHiddenInput.value = this.value;
}

That way, if a button was used to submit the form, the button's handler sets the value of the hidden input prior to the submit.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!