Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

307
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda