Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

104
Visualizações
Getting data from JSON with arrays

I am getting a little stuck with this one. I am trying to use jquery on my website to change an element. Without using an array of data in JSON, it works fine but soon as I use an array of data in there, it stops working. I have tried multiple searches online and tested around myself but I can't seem to get it to work. Surely it should be as simple as below? (I am passing data into this so the server can get commands back if you wondered what the x is for. This bit works fine.)

The following is simple version of the JSON data I am working with:

{"OUTPUTA":"TRUE","OUTPUTB":"TRUE"},{"OUTPUTC":"FULSE","OUTPUTD":"TRUE"}

Script used:

function update(x) {
$.getJSON('/_ConfigJSON', {
    buttondata: x,
}, function (data) {
        $("#BUTTONA").text(data.[1][OUTPUTA]);
        }
  });
}

Working version (without array data):
"OUTPUTA":"TRUE","OUTPUTB":"TRUE","OUTPUTC":"FULSE","OUTPUTD":"TRUE"

Script used:

function update(x) {
$.getJSON('/_ConfigJSON', {
    buttondata: x,
}, function (data) {
        $("#BUTTONA").text(data.OUTPUTA);
        }
  });
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Your code is syntactically incorrect.

Here's the updated code:

function update(x) {
$.getJSON('/_ConfigJSON', {
    buttondata: x,
}, function (data) {
        // Gets the second element.
        $("#BUTTONA").text(data[1]["OUTPUTA"]);
        }
  });
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda