gpt4 book ai didi

Javascript 表单提交等待完成

转载 作者:行者123 更新时间:2023-11-30 13:00:11 24 4
gpt4 key购买 nike

我有一个上传的表单

<form action="../upload" method="post" id="upload_form" enctype="multipart/form-data" target="upload_frame" >
<input name="file" type="file" />
</form>

它是使用 javascript 表单提交的另一个表单提交按钮

function upload(){
var uploadForm = document.getElementById('upload_form');

uploadForm.submit();
console.log('this should be called when the form finishes upload and respone is committed');

}

例子不够清楚请指出

最佳答案

将 onload 处理程序添加到您的 iframe。服务器响应请求后调用。

例如:

var uploadFrame = document.getElementsByName('upload_frame')[0];

function handleResponseReceived() {
console.log('this should be called when the form finishes upload and respone is committed');
}

if (uploadFrame.addEventListener) {
uploadFrame.addEventListener('load', handleResponseReceived, false);
}
else {
uploadFrame.attachEvent('onload', handleResponseReceived);
}

关于Javascript 表单提交等待完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17512633/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com