Taking recommendations that I have read I am sending 2 methods. In the first I send the concepts, including the list and in the second I send the images. The first method is sent perfectly and from it I must receive the transaction number which I pass as a parameter to the second method. To do this, I place the transaction number in an input. But I have a problem because when I retrieve the value of the input I do not get the value that I entered, it always gives me zero. The second method runs well and the images are received, but I receive the transaction number variable as zero. The code is the following.
function AdicionarMovimiento() {
if ($("#cbbentidad").val() == 0 || $("#cbbentidad").val() == null) {
swal("", "Debe seleccionar una entidad.", "warning");
return
}
EnviarTransaccionOperacion();
EnviarImagenesenTransaccionOperacion();
}
function EnviarTransaccionOperacion() {
var transaction = {
movConductor: "@User.Identity.Name",
movIdTransaction: "2",
movNumero: 0,
movEntidad: $("#cbbentidad").val()
}
var lista_conceptos = [];
$("#tabla tbody tr").each(function (index) {
var concepto = $(this).find("td").eq(0).html();
var check = $(this).find("input").prop('checked');
var calificacion = "NO CUMPLE"
if (check) {
calificacion = "CUMPLE";
}
lista_conceptos.push({
movNumero: 0,
movIdTransaction: 2,
movConcepto: concepto,
movCalificacion: calificacion
})
})
console.log(lista_conceptos);
jQuery.ajax({
url: '@Url.Action("RegistrarInspeccion", "Transactions")',
type: "POST",
data: JSON.stringify({ oTransaction: transaction, listaconceptos: lista_conceptos }),
datatype: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
console.log(data)
$("#txtNumero").val(data.numeromovimiento);
}
},
})
}
function EnviarImagenesenTransaccionOperacion() {
var transaction = {
movConductor: "@User.Identity.Name",
movIdTransaction: "2",
movNumero: 0,
movEntidad: $("#cbbentidad").val()
}
var ImagenSeleccionada1 = $("#fileProducto1")[0].files[0];
var ImagenSeleccionada2 = $("#fileProducto2")[0].files[0];
var ImagenSeleccionada3 = $("#fileProducto3")[0].files[0];
var request = new FormData();
request.append("objeto", JSON.stringify(transaction));
request.append("numeromovimiento", $("#txtNumero").val());
request.append("archivoImagen1", ImagenSeleccionada1);
request.append("archivoImagen2", ImagenSeleccionada2);
request.append("archivoImagen3", ImagenSeleccionada3);
jQuery.ajax({
url: '@Url.Action("RegistrarInspeccionImagenes", "Transactions")',
type: "POST",
data: request,
processData: false,
contentType: false,
success: function (data) {
}
})