Basic error in Javascript

Asked

Viewed 28 times

-2

Good morning guys, can anyone tell me why I’m getting the bug

Syntaxerror: Missing ) after argument list , in line 14 in the following code:

$(document).ready(function() {

      var $div_novospedidos = $('#div_novospedidos');
      $div_novospedidos.empty(); //Limpando a tabela
      // setTimeout(function(){ location.reload(); }, 5000);
      $.get("database3.php", function(data, status) {
          //if (data == null) {console.log("sem pedidos hoje")} else {console.log("teste")};
          var dados_pedido = data;
          console.log(dados_pedido);
          const obj = dados_pedido;
        }

        var dados = $.parseJSON(data); console.log(dados); $.each(dados, function(i, item) {
          numeroPedido = item.doc_number;
          nomeCliente = item.client_name;
          horarioPedido = item.clock;

          var newReq = $('<div class="panel panel-default col-6 col-lg-4 ">');
          var cols = "";

          cols += '<p>HORARIO: ' + horarioPedido + '</p></div>';
          cols += '<p>PEDIDO: ' + numeroPedido + '</p></div>';
          cols += '<p>Cliente: ' + nomeCliente + '</p></div>';

          newReq.append(cols);

          $("#div_novospedidos").append(newReq);

        });
      }
  • You have a } lost in the code before var dados. And this . ready( is not closed.

1 answer

0


Missed closing the stretch where you do the $.get('database3.php', function (data, status) {.

Just add the ) before the stretch that has var dados. Also missing close with the ) the last line, that is, after the last } of the function used in $(document).ready(function () {;

I suggest using some IDE that you can, in real time, check for syntax errors, so you can avoid wasting time or embargoes like this.

I found it easy by using VS Code.

Behold:

Checagem de Sintaxe no VSCODE

Browser other questions tagged

You are not signed in. Login or sign up in order to post.