Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

217
Visualizações
Error: Uncaught SyntaxError: missing ) after argument list - JS function

I used arrays for my table :

var html = [];
$.each(data,function(index,item){
   no++;
   var arr = [
    '<tr>',
       '<td>'+ no +'</td>',
       '<td>'+ item.name +'</td>',
       '<td>'+ item.address +'</td>',
       '<td>',
         '<button type="button" class="btn btn-info btn-sm" onclick="pickData('+ item.id +','+ item.name +','+ item.address +')"><i class="fas fa-plus-circle"></i></button>',
    '</td>',
    '</tr>'
    ].join('\n');
    html.push(arr);
});
$('#table').html(html);

and this is the function :

function pickData(id, name, address) {
    $("#id").val(id);
    $(".name").val(name);
    $(".address").val(address);
}

The error is :

Uncaught SyntaxError: missing ) after argument list

Where is the problem?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

From the way you write code, Please check your variable (especially address and name) value from console.log, Make sure it doesn't contains space on it.

Ie. "Malibu" Vs "Malibu street",

If it does contains space, you need to quotes those variable value. Because when you're not place quotes, your function would be invoked like this: pickData("yourId", "yourName", Malibu street)

Meanwhile the function itself expect like this: pickData("yourId", "yourName", "Malibu street")

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda