Is there an “after submit” jQuery option?

后端 未结 4 590
执笔经年
执笔经年 2020-12-03 02:31

I have a form that uploads a file and targets an iframe on the page. When the user clicks submit, I want the file contents to \"clear\" out.

I tried this

<         


        
4条回答
  •  悲&欢浪女
    2020-12-03 03:14

    Lonesomeday's solution worked for me but for Google Chrome I found it would still submit empty form data unless I added a timeout like this:

    $('#imageaddform').submit(function(e) {
        e.preventDefault(); // don't submit multiple times
        this.submit(); // use the native submit method of the form element
    
        setTimeout(function(){ // Delay for Chrome
            $('#imagefile').val(''); // blank the input
        }, 100);
    });
    

提交回复
热议问题