admin管理员组文章数量:1428340
I have a form with upload
<form action="../upload" method="post" id="upload_form" enctype="multipart/form-data" target="upload_frame" >
<input name="file" type="file" />
</form>
and it's submit using javascript form another form submit button
function upload(){
var uploadForm = document.getElementById('upload_form');
uploadForm.submit();
console.log('this should be called when the form finishes upload and respone is mitted');
}
please tell if the example is not clear enough
I have a form with upload
<form action="../upload" method="post" id="upload_form" enctype="multipart/form-data" target="upload_frame" >
<input name="file" type="file" />
</form>
and it's submit using javascript form another form submit button
function upload(){
var uploadForm = document.getElementById('upload_form');
uploadForm.submit();
console.log('this should be called when the form finishes upload and respone is mitted');
}
please tell if the example is not clear enough
Share Improve this question asked Jul 7, 2013 at 13:35 Mohamed Wagdy KhorshidMohamed Wagdy Khorshid 5574 gold badges15 silver badges32 bronze badges 1- @Yve I understood it as "I want to know when the server has received the request and responded". In other words, it looks like the OP is looking for a way to determine when the file has been sent to the server by checking for a response client-side. – Ray Nicholus Commented Jul 7, 2013 at 14:08
1 Answer
Reset to default 3Add an onload handler to your iframe. It will be called after the server responds to the request.
For example:
var uploadFrame = document.getElementsByName('upload_frame')[0];
function handleResponseReceived() {
console.log('this should be called when the form finishes upload and respone is mitted');
}
if (uploadFrame.addEventListener) {
uploadFrame.addEventListener('load', handleResponseReceived, false);
}
else {
uploadFrame.attachEvent('onload', handleResponseReceived);
}
本文标签: htmlJavascript form submit waiting till finishesStack Overflow
版权声明:本文标题:html - Javascript form submit waiting till finishes - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745523468a2661734.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论