3
I have the following table:
This table is dynamic and works like form, IE, the user when clicking Novo
a new row is created with the dynamic fields. By clicking Salvar Dados
all user-created lines are saved. So far so good. But what I’m doing is giving the user the possibility to insert Files, so I have a input type="file"
also dynamic for each line (this to hidden
), where to upload the data to the controller
from a ajaxSubmit
(I’m working on ASP MVC 4).
My problem now it is:
By doing the ajaxSubmit
, the javascript
is overwriting data from id's
dynamics that I have for the input file
. Follows the function:
function submitDocCertISCC(numID, DivNrFicha) {
$("#formSaveFile" + numID + "_" + DivNrFicha + "").ajaxSubmit({
type: "POST",
url: $("#formSaveFile").attr("action"),
clearForm: true,
data: { numID: numID, DivNrFicha: DivNrFicha }
});
}
I call the function up while running a cycle for
where I will store each row of the table at a time, and it works well. Now comes the part of saving the file and only saves the file from the last row. As far as I can tell, he’s going to the next step of the cycle for
without first finishing doing the ajaxSubmit
.
How can I get around this and make him not jump the cycle without finishing this function?
EDIT
Cycle For
:
for (var i = 1; i <= window.numAutoDeclaracaoISCC; i++) {
$.getJSON("/Terceiros/saveAutoDeclar", { // Gravar dados da linha
DivNrFicha: DivNrFicha, dtaEmissao: dtaEmissao, NumAutoDeclar: NumAutoDeclar, DtValid: DtValid, EmitidoPor: EmitidoPor,
Anexo: Anexo, DtEntregaTec: DtEntregaTec, DtRecepcao: DtRecepcao
},
function (result) {
submitDocCertISCC(i, DivNrFicha); // Fazer submit do form com o ficheiro
});
}
Can show wider code context?
– bfavaretto
Updated. In the for cycle I did not upload the data to be sent to
.getJSON
, I do not think it is important for the issue– CesarMiguel
Aha, now it’s clear the problem.
– bfavaretto