I get the following error: TypeError: data is null

I get the following error: TypeError: data is null

klermannklermann Posts: 277Questions: 67Answers: 1

Hello Allan, when I try to create an item inside the datatable in the consol, I get the following error: TypeError: data is null. The object returns normally but, after being created but, the modal window does not close resulting in the error.
Login: admin@admin.com
pass:admin
ec2-34-224-65-226.compute-1.amazonaws.com:8080/financeiro/receitas/

This question has an accepted answers - jump to answer

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    moment.min.js is not loading for me.

  • klermannklermann Posts: 277Questions: 67Answers: 1
    edited March 2018

    Loading here - https://prnt.sc/inv8z7

  • allanallan Posts: 63,332Questions: 1Answers: 10,436 Site admin
    Answer ✓

    The error message I see in the console is:

    configReceitas.js:478 Uncaught TypeError: Cannot read property '0' of null
    at mRender (configReceitas.js:478)

    Looking at that block of code I see:

                        {
                            data: "etiquetas",
                            mRender: function(data){
                                if(data != 0 || data.length != 0){
                                    url = data[0].id;
                                    urlSend = '<a class="hightlight" href="/financeiro/tags/movimentacaoPorEtiqueta/' +
                                    data[0].nome + '">' + data[0].nome + '  <i class="fa fa-external-link font-size-10" aria-hidden="true"></i></a>';
                                    return urlSend;
                                }
                                return "Sem etiqueta";
                            },
                        },
    

    So the error message means that data is null. Your code isn't checking for that, so you need to either allow for that in the code or correct the data if it shouldn't be null.

    Allan

  • klermannklermann Posts: 277Questions: 67Answers: 1

    Thanks

This discussion has been closed.