Good afternoon everyone,
I’m having trouble accessing the attributes of a JavaScript object array through AJAX. Can anyone spot where I might be going wrong?
This is my AJAX call:
$("#cbx1").on("change", function() {
var checkbox = $("#cbx1").val();
console.log(checkbox);
if(checkbox == "TF") {
var url = "/listar-perguntas?area-tematica=" + $(this).val() + "&montar-navegadores=true";
console.log("bateu aqui 1"+url);
} else {
var url = "/listar-perguntas?area-tematica=" + $(this).val();
console.log("bateu aqui 2"+url);
}
$.ajax({
type:'GET',
data : "",
url: url,
contentType: "application/json; charset=utf-8",
success: function(data) {
console.log(data);
let text = "<input>"
for (let x in data) {
text += "<label>" + data[x] + "</label>"
}
text += "</input>"
document.getElementById("temaFederal").innerHTML = text;
},
error: function(data){
console.log(data.statusText);
}
});
In my HTML, it appears as follows: