JQuery image upload not work for future event

后端 未结 1 1270
梦谈多话
梦谈多话 2021-01-25 22:39

I want to my user can upload image with post. So with every reply form have a upload form also. User can upload a image by click upload button and then click submit to submit po

相关标签:
1条回答
  • 2021-01-25 23:25

    You might need to reset the file form:

    $("form.upload_Reply")[0].reset();
    $("form.upload_Reply").trigger("reset");
    

    Also, you can get more debugging information from your AJAX call. Try writing error/success data to the console:

    $('.upload_Reply').on('submit', function(e){
        e.preventDefault();
        var EID = $(this).attr('id');
        $('.loading').show();
            $.ajax({
            type:"post",
            url:"../upload.php",
            data:  new FormData(this),
            contentType: false,
            cache: false,
            processData:false,
            success: function(response, statusText, xhr){
                console.log(response);
                console.log(statusText);
                console.log(xhr);
                $('#img'+ EID).attr('value', response);
            },
            error: function(xhr, statusText, errorThrown){
                console.log(errorThrown);
                console.log(statusText);
                console.log(xhr);
            },
        });
        return false;
    });
    
    0 讨论(0)
提交回复
热议问题