Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Exemplo de acordo com o que pediste.
- * 1) - Ficheiro index.php = ficheiro que contém a tabela
- * 2) - Ficheiro ajax.php = ficheiro que vai receber os dados da tabela do index.php
- */
- index.php
- <html>
- <head></head>
- <body>
- <table id="tabela_XPTO">
- <tr>
- <td>Novos</td>
- <td>Horizontes</td>
- </tr>
- </table>
- <button id="button_XPTO">Clica-me fax fabor!</button>
- <script>
- $(document).on('click', '#button_XPTO', function(){
- var values = [];
- $("#tabela_XPTO").find('tr').each(function(){
- var $td = $(this).find('td');
- values.push({'id': $td.eq(0).text(), 'nome': $td.eq(1).text()});
- /* $td.eq(0).text = "novos" :: $td.eq(1).text = "horizontes" */
- });
- $.post('responses/ajax.php', {valores: values}, function(aux){
- console.log(aux);
- });
- });
- </script>
- </body>
- </html>
- ajax.php
- print_r($_POST);
- // E em princípio receberás na consola do Chrome os valores.
- // Depois é só pegares neles e inserires na base de dados.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement