Heim  >  Fragen und Antworten  >  Hauptteil

javascript - Chrome浏览器不能连续上传相同的图片,第二次无请求,页面采用jquery.form.js插件异步提交?

html:
<form id="uploadForm">
    <input id="img" class="hidden" type="file" name="file" />
</form>
脚本:
$('#uploadForm').ajaxSubmit({
    url: '……',
    type: 'post',
    async: true,
    cache: false,
    dataType: 'json',
    contentType: 'multipart/form-data',
    beforeSend: function(){//发送前
                
    },
    complete: function(){//发送后
                
    },
    success: function(data){//请求成功
                 
    },
    error: function(response, textStatus, errorThrown){//请求失败
                 
    }
});
高洛峰高洛峰2723 Tage vor274

Antworte allen(1)Ich werde antworten

  • ringa_lee

    ringa_lee2017-04-11 13:15:09

    你需要在完成时,重置表单,在请求成功之后 加入
    $('input[type=file]').wrap('<form>').closest('form').get(0).reset();

    Antwort
    0
  • StornierenAntwort