Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

304
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!