I am facing an error ‘data’ is undefined when trying to access the function parameter as mentioned in the comment in below code

Solution
            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= '
' for (i = 0; i < capacitylist.length; i++){ text = capacitylist[i]['label']; result='' middle+=result } end='
' botHtml=start+result+end $(".chat_block").append(botHtml); }); }