0
have this the following JSON file with the name test.json:
"registro":[
{"cnpj":"46148234000117","serie":"1","numero":"1"},
{"cnpj":"46148264000117","serie":"1","numero":"2"},
{"cnpj":"46148224000117","serie":"1","numero":"3"},
{"cnpj":"46148274000117","serie":"1","numero":"4"},
{"cnpj":"46148294000117","serie":"1","numero":"5"},
{"cnpj":"46148204000117","serie":"1","numero":"6"},
{"cnpj":"46148294000117","serie":"1","numero":"7"},
{"cnpj":"46148244000117","serie":"1","numero":"8"},
{"cnpj":"46148247000117","serie":"1","numero":"9"},
{"cnpj":"46148242000117","serie":"1","numero":"10"},
];
and I have this JS function:
$.getJSON("teste.json", function( data ) {
var registro = data.registro;
$.each(data, function(cnpj, numero){
registro.push("<li id='" + cnpj +"'>"+ numero + "</li>");
});
$("<ul/>", {
"class": "my-new-list",
html: registro.join("")
}).appendTo("body");
});
I would like to list exactly how it is in the file, but I don’t know where is the error in my function
the error occurs where? " $. getJSON("test.json", Function( date )" ?
– RDyego
likely, because it’s showing nothing
– Samuel Nicolau
I believe I must create a loop of repetition
– Samuel Nicolau
and then I need to check if you skipped a number
– Samuel Nicolau
I put an answer, then check it.
– RDyego