Take JSON information and insert into the loop html using getJson

Asked

Viewed 491 times

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 wonder how I can get the information from php via getJSON and make a loop to insert into the table when loading the page?

$(document).ready(function(){


});
  • You can put a piece/example of the JSON you have?

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.


});

Browser other questions tagged

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