I have the following table:
Thistableisdynamicandworkslikeform,thatis,theuserclickingNovo
createsanewrowwiththedynamicfields.WhenyouclickSalvarDados
alllinescreatedbytheuseraresaved.Sofarsogood.ButwhatI'mdoingisgivingtheuserthepossibilitytoinsertfiles,forthatIhaveainputtype="file"
also dynamic for each line (this is the hidden
), where it will load the data to controller
from a ajaxSubmit
(I'm working on ASP MVC 4).
My problem is now:
When doing ajaxSubmit
, javascript
is overlapping the id's
dynamic data I have for input file
. Here is 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 when running through a for
loop where I'll save each row of table at a time, and it works fine. Now comes the save part of the file and only writes the file from the last line. As it seems to me, it goes to the next step of the for
cycle without first finishing the ajaxSubmit
.
How can I circumvent this and make it not jump in the loop 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
});
}