0
Good afternoon, Stack Overflow.
I’m feeling huge difficulty getting content from a specific javascript array.
In the first lines of javascript code it looks like this.
Loose
var arrayIDs = [];
After a while, it executes the following code
$(".form-group").find('*').each(function() {
var id = $(this).attr("id");
if ($("#" + id).val() > 0) {
if ($("#" + id).data("id-produto-item") != undefined) {
arrayIDs.push({
id_produto_itens: $("#" + id).data("id-produto-item"),
id_proposta: numeroProposta
});
}
}
});
After the data is filled in, I ultimately need to manipulate them.
When I give a.log console in ID arrays, this appears to me here:
*→ []
→ 0: {id_produto_itens: 150, id_proposta: "123"}
→ 1 : {id_produto_itens: 160, id_proposta: "123"}
→ 2: {id_produto_itens: 176, id_proposta: "123"}
→ 3: {id_produto_itens: 175, id_proposta: "123"}
length: 4__proto__: Array(0)*
The problem occurs when I want to scroll through the values as follows, so it doesn’t even enter into the $.each
No error message or anything, so when I put a console.log("message") or enter this "message"
$(document).on('click','#btnSalvar',function () {
$.each(arrayIDs, function (key, value) {
console.log("mensagem")
console.log(arrayIDs.id_produto_itens);
});
});
The question is, how to get the contents of this array?
Edit 1: I will put exactly when each stretch is called
Hello Abriel, some answer solved your problem?
– Sergio