Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="fr">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Projet 2</title>
- <!-- Bootstrap CSS -->
- <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
- <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
- <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
- <!--[if lt IE 9]>
- <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.3/html5shiv.js"></script>
- <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
- <![endif]-->
- <style>
- .box {
- border: 1px red solid;
- padding: 10px;
- }
- </style>
- </head>
- <body>
- .
- <div class="container">
- <div class="row">
- <div id="users">
- <legend>Liste des utilisateurs</legend>
- <div class="status">
- </div>
- <div class="row">
- <!-- est affiché comme ça -->
- <div class="col-md-6 box" id="box-id">
- <div id="name">name (username) <br></div>
- <div id="email">email <br></div>
- <div id="adress">street suite à city (zipcode) <br></div>
- <div id="localisation"> <br></div>
- <div id="phone">phone <br></div>
- <div id="website">website <br></div>
- <div id="company">company_name</div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- jQuery -->
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
- <!-- Bootstrap JavaScript -->
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
- <script>
- $(function () {
- var statut = $('.status');
- // $(".status").text("Chargement en cours ...");
- $.ajax({
- type:'GET',
- url: 'https://jsonplaceholder.typicode.com/users',
- dataType : 'json',
- timeout: 4000,
- success: function (result) {
- // for(i = 0; i<result.length ; i++ ){
- // $('#name').html(result[i].name);
- // $('#email').html(result[i].email);
- // $('#adress').html(result[i].address);
- // $('#localisation').html(result[i].address.geo.lat + ' (lat) ').append(result[i].address.geo.long + ' (long)');
- // $('#phone').html(result[i].phone);
- // $('#website').html(result[i].website);
- // $('#company').html(result[i].company.name);
- // console.log(result[i].company.name);
- // }
- for(i = 0 ; i<result.length; i++ ){
- $('#box-id').clone().appendTo($('.status'));
- }
- },
- error: function() {
- statut.text("RIP une erreur est survenue");
- }
- });
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement