Typeerror: $(...). tableToJSON is not a Function

Asked

Viewed 188 times

0

Greetings Clicking on the Button in my project shows the following Typeerror: $(...). tableToJSON is not a Function, I am using the tableToJSON plugin

Code:

$('document').ready(function(){
    $('#TermVenda').click(function(){
        var table =$('#products-table').tableToJSON(); 
        console.log(table);
        document.write(JSON.stringify(table));
        alert(JSON.stringify(table));
    });           
 });             

HTML table: <!DOCTYPE html> <html> <head> <title>Pagina do Cliente</title> <script type="text/javascript" src="js/jquery-1.11.3.min.js"></script> <script type="text/javascript" src="js/jquery.tabletojson.min.js"></script> </head> <body> <table id="products-table" class="table table-hover table-bordered"> <thead> <tr> <th>Produto</th> <th>Preço </th> <th>Qtd</th> <th>Valor</th> <th>Ações</th> </tr> </thead> <tbody> <tr> <td>Banana</td> <td>20</td> <td>5</td> <td>100</td> <td>x</td> </tr> <tr> <td>Alho</td> <td>20</td> <td>5</td> <td>100</td> <td>x</td> </tr>
</tbody> </table> <button id="TermVenda">Converter</button> </body> </html>

  • You have built jquery.tabletojson.js into your page ?

  • Yes they are all included there

  • You may have included jquery.tablejson.js before including jquery.js. Change the question and post html with the js included as well.

1 answer

1


Maybe you didn’t include the jquery or jquery.tabletojson.js on your page. Open your Developer console by pressing F12 on your browser, and make sure there are no JS loading errors. I set up a test page, as the link below and works correctly.

Tabletojson DEMO Page

inserir a descrição da imagem aqui

Browser other questions tagged

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