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

310
Visualizações
I am facing an error 'data' is undefined when trying to access the function parameter as mentioned in the comment in below code
function categoryDetails(catId, code, label) {
  alert('Inside Categories Detail')
  $.post("/product/categories", {
    catId: catId,
    code: code,
    label: label,
    sess: socket.id
  }).done(function(data) {
    alert("Inside product capacity" + data.result)
    console.log(data.result)
    //In the below line I am trying to access the data parameter of the function but it says undefined
    var botHtml = '<div class="nn-bot-bubble"><div class="nn-bot-chips">{% for i in data.result %}<button id="sel_btn" value="{{ i.label }}"> {{ i.label }} </button>{% endfor %}</div></div>'
    $(".chat_block").append(botHtml);
  });

Here the data parameter is a dictionary with the key named 'result' and value a 'list'. Thanks in advance!!!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

            function categoryDetails(catId,code,label){
            alert('Inside Categories Detail')
            $.post("/product/categories", {catId: catId,code:code,label:label, sess: socket.id}).done(function(data) {
                var text='';
                var middle='';
                var result='';
                capacitylist=data.result
                var start= '<div class="nn-bot-bubble"><div class="nn-bot-chips"><div class="button_block">'
                for (i = 0; i < capacitylist.length; i++){
                    text = capacitylist[i]['label'];
                    result='<button id="sel_btn" value="'+text+'">'+text+'</button>'
                    middle+=result
                }
                end='</div></div></div>'
                botHtml=start+result+end
                $(".chat_block").append(botHtml);
            });

        }

So here instead of running a loop inside the DOM, I used a javascript loop and then combined it.

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