문제

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 committed');

}

please tell if the example is not clear enough

도움이 되었습니까?

해결책

Add 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 committed');
}

if (uploadFrame.addEventListener) {
    uploadFrame.addEventListener('load', handleResponseReceived, false);
}
else {
    uploadFrame.attachEvent('onload', handleResponseReceived);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top