jQuery giving "Unexpected token;" problem in variable assignment

0

I use this code below to load on the display of a DataTable values according to what the user selects, it is not possible to use the default DataTable and must be so I can request the server the required amount. The code below is how this is done

1 if ( $("#ITENSPAGINA").change() ){
2     var valor = $("#ITENSPAGINA").val();
3
4     $('#TABELACTRECEBER').DataTable({
5             "pageLength": valor;    // informa ao DataTable a quantidade que deve ser exibida na tabela
6         }
7     );
8 }

This way it works, it works as expected, but I'm having another problem that starts from this algorithm (line 5)

(ignorelinenumber)

Andaswiththiserrorpresentedinthefirstimage,noJavaScriptalgorithmworksafterthis,forallIgetthesametypeoferror:

NowifIsimplyremovethe";" (line 5)

1 if ( $("#ITENSPAGINA").change() ){
2     var valor = $("#ITENSPAGINA").val();
3
4     $('#TABELACTRECEBER').DataTable({
5             "pageLength": valor
6         }
7     );
8 }

The above jQuery code stops working but all other JavaScripts on the page re-start.

I need this jQuery code to work this way so that I have my table working correctly and I need the JavaScripts on the page working properly. That is, everyone needs to work. What I would need would be just to be able to use the variable without the ";" inside jQuery but still work the same.

Although the title seems to be a duplicate question, I did not find any question with this kind of problem, not "Unexpected token;" but a problem of; inside a jQuery for using an indispensable variable.

    
asked by anonymous 26.09.2018 / 15:10

0 answers