Get JSON information and insert into html with loop using getJson

0

Next, I have a table in an html page, example:

<table>
            <tr>
                <th>nome</th>
                <th>e-mail</th>
            </tr>
            <tr>
                <td>Jill</td>
                <td>Smith@mail</td>
            </tr>
            <tr>
                <td>Eve</td>
                <td>Jackson@email</td>
            </tr>
</table> 

And I have a script in php that returns me name and user email in JSON format, I would like to know how can I get the php information via getJSON and loop to insert into the table when loading the page?

$(document).ready(function(){


});
    
asked by anonymous 13.05.2017 / 06:56

1 answer

1
 $.get("pagina.php", {"parametros": "valores", "parametros2": "valores"}, function(data)
{

var retorno = JSON.parse(data);//este retorno sera um array ou um object entao e so usar um loop for para varre-lo.


});
    
13.05.2017 / 17:04