"Uncaught SyntaxError: missing) after argument list" in .append JQuery

0

I'm getting "Uncaught SyntaxError: missing" after argument list "which accuses the line of the last closed parentage, this inside the callback of a jquery post. I tried to close anyway possible, and even then I get the error. I do not understand how these parentheses have to be closed.

$("#exchangers tbody").append(
    $("<tr class='tr_row' id='tr_" + elPosition + "'>").css({cursor:'pointer'}).append(
        $("<td id='td_" + elPosition + "'>").append($("<i id='io" + elPosition + "' onmousedown='shc(" + elPosition + ")' onclick='stopBubbling(event)' onmouseover=\"show_info(" + elPosition + ", '" + el.nome + "', '" + el.https + "', '" + el.moeda_from + "', '" + el.moeda_to + "', '" + el.idade + "', '" + el.url_redirect + "', '" + el.wmid + "', '" + el.pais_nome + "', '" + el.rank_from + "', '" + el.rank_to + "', '" + el.amount + "')\" onmouseout='shd(" + elPosition + ")'>").addClass('fa fa-info-circle io').html("")),
        $("<td>").html('<a class="a_row" href="' + URL_SITE + '/click/' + el.exchange_rates + '.html" target="_blank">' + el.nome + '</a>'),
        $("<td>").html(el.in + " " + el.from),
        $("<td>").html(el.out + " " + el.to),
        $("<td>").html(el.amount + " " + el.to),
        $("<td class='a_comment text-center'>").append(
            '<a class="a_row" style="width: 90px !important;" href="' + URL_SITE + '/exchangers/' + el.link_permanente + '.html">',
            $('<span>').append(
                $('<span>').addClass('text-danger').html(parseInt(el.reviews[0]["negativo"])),
                "/",
                $('<span>').addClass('text-success').html(parseInt(el.reviews[0]["positivo"]) + parseInt(el.reviews[0]["comentario"]) + parseInt(el.reviews[0]["negativo"])),
            ),
            '</a>'
        )
    );

Commenting the code in parts, I noticed that the error comes from here:

$("<tr class='tr_row' id='tr_" + elPosition + "'>").css({cursor:'pointer'}).append(
     $("<td id='td_" + elPosition + "'>").append($("<i id='io" + elPosition + "' onmousedown='shc(" + elPosition + ")' onclick='stopBubbling(event)' onmouseover=\"show_info(" + elPosition + ", '" + el.nome + "', '" + el.https + "', '" + el.moeda_from + "', '" + el.moeda_to + "', '" + el.idade + "', '" + el.url_redirect + "', '" + el.wmid + "', '" + el.pais_nome + "', '" + el.rank_from + "', '" + el.rank_to + "', '" + el.amount + "')\" onmouseout='shd(" + elPosition + ")'>").addClass('fa fa-info-circle io').html(""))

Am I forgetting to escape something?

    
asked by anonymous 23.02.2018 / 11:55

1 answer

1

PerduGames, What I did in your code:

  • I added a parentheses at the end before the ';' to close the first jquery append function;
  • I changed the double quotation marks \ "in the onomouseover call to apostrophe '(or single quotation mark);
  • I have removed an extra comma in the last append.

You normally performed here.

var elPosition = 1;
var URL_SITE = 'http:www.com';

var el = {
  nome: 'Cleyton',  https: 'Sim', moeda_from: 'USD', moeda_to: 'BRL', idade: 100, url_redirect: 'Pagamento', wmid: 1, pais_nome: 'For for way', rank_from: 1, rank_to: 2, amount: 1.00, in: 'entrada', out: 'saida', from: 'Joaquim', to: 'Pedro', reviews:[{negativo: 2,positivo: 5,comentario: 2}]
};



$("#exchangers tbody").append(
    $("<tr class='tr_row' id='tr_" + elPosition + "'>")
        .css({cursor:'pointer'})
        .append(
            $("<td id='td_" + elPosition + "'>")
                .append(
                    $("<i id='io" + elPosition + "' onmousedown='shc(" + elPosition + ")' onclick='stopBubbling(event)' onmouseover='show_info(" + elPosition + ", '" + el.nome + "', '" + el.https + "', '" + el.moeda_from + "', '" + el.moeda_to + "', '" + el.idade + "', '" + el.url_redirect + "', '" + el.wmid + "', '" + el.pais_nome + "', '" + el.rank_from + "', '" + el.rank_to + "', '" + el.amount + "') onmouseout='shd(" + elPosition + ")'>")
                    .addClass('fa fa-info-circle io')
                    .html("")
                ),
            $("<td>").html('<a class="a_row" href="' + URL_SITE + '/click/' + el.exchange_rates + '.html" target="_blank">' + el.nome + '</a>'),
            $("<td>").html(el.in + " " + el.from),
            $("<td>").html(el.out + " " + el.to),
            $("<td>").html(el.amount + " " + el.to),
            $("<td class='a_comment text-center'>").append(
                '<a class="a_row" style="width: 90px !important;" href="' + URL_SITE + '/exchangers/' + el.link_permanente + '.html">',
                $('<span>').append(
                    $('<span>').addClass('text-danger').html(parseInt(el.reviews[0]["negativo"])),
                    "/",
                    $('<span>').addClass('text-success').html(parseInt(el.reviews[0]["positivo"]) + parseInt(el.reviews[0]["comentario"]) + parseInt(el.reviews[0]["negativo"]))
                ),
                '</a>'
            )
        )
    );
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <table id='exchangers'>
    <tbody>
    </tbody>
  </table>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>

</body>
</html>
    
23.02.2018 / 14:06