Last active
July 24, 2017 17:23
-
-
Save rodrigobravo/46d8f9d5b41552d9f513cc22bcb64293 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(function(){ | |
| var $tabela_novospedidos = $('#tabela_novospedidos'); | |
| $tabela_novospedidos.empty(); //Limpando a tabela | |
| $.ajax({ | |
| type:'post', //Definimos o método HTTP usado | |
| dataType: 'json', //Definimos o tipo de retorno | |
| url: 'database.php',//Definindo o arquivo onde serão buscados os dados | |
| success: function(dados){ | |
| var dados_pedido = dados; | |
| console.log(dados_pedido); | |
| $(function(){ | |
| const obj = $.makeArray(dados_pedido) | |
| const makeData = (obj) => obj.map(values => { | |
| return `<tr> | |
| <td>${values.acumulador}</td> | |
| <td>${values.data}</td> | |
| <td>${values.hora}</td> | |
| <td>${values.cliente}</td> | |
| <td>${values.endereco}</td> | |
| <td>${values.obs}</td> | |
| </tr>`; | |
| }).join('') | |
| /* const renderData = (obj, target) => { | |
| $(target).html(makeData(obj)) | |
| } | |
| */ | |
| const renderData = (obj, target) => { | |
| const verifiedData = Array.isArray(obj) ? obj : [].concat(obj) | |
| $(target).html(makeData(verifiedData)) | |
| } | |
| renderData(obj, "#tabela_novospedidos") | |
| }) | |
| } | |
| }); | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment