There is a form: enter image description here

When opened, it looks like this:

enter image description here

When clicking on add file:

enter image description here

After adding a file - the old button hides and a new one becomes in its place. Now to the heart of the problem:
In Google Chrome, all code is executed validly - the data is sent well, not duplicated.
But when sending data through Mozilla firefox, the file is sent in some way 2 times, to send data from the form I use the following code:

"use strict"; $("#form_client_data_value").validate({ debug: false, onfocusout: false, onKeyUp: true, submitHandler: function (form) { if ($(form).find('input[type=file]').length > 0) { $(form).append("<iframe src='#' id='upload_frame' name='upload_frame' style='opacity: 0; width: 0; height: 0; border: 0;'></iframe>") .attr("enctype", "multipart/form-data") .attr("method", "POST") .attr("file", "true") .attr("target", "upload_frame"); form.submit(); $("#end_document_download").modal('show'); } } }); $("button[data_user_check]").on('click', function () { $.ajax({ url: $("#form_client_data_value").attr('action'), cache: false, async: false, success: function (html) { var contents = $(html).find("#content_user_replace"); $("#content").html($(contents)); } }); $("#end_document_download").modal('hide'); }); 

There is also such a problem that Replacing a file is also an input and when sending data when copying a form to an iframe - the entire form is copied, i.e. all inputs, including replacements for the file, but of course only the files that the user attached under the add file are sent , is it possible to somehow facilitate the task of sending files, what needs to be done for this, you can somehow do so that only the input file types from "Add files" are taken, I am new to js, ​​jq, please do not kick much and tell everything is available and it is clear that there is no question in the html structure, I insert into the pasteherbin the html part responsible for the form

Link to code .

    1 answer 1

    It is necessary to suspend the first submission of the form, which occurs after calling the submitHandler function.

    At the end of the submitHandler function, add return false;

    Source - https://stackoverflow.com/questions/10798717/preventing-a-form-from-submitting-in-jquery-validate-plugins-submithandler-func .

    Or if the form is sent 2 times through the iframe, then simply remove this line form.submit();