Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 3.48 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="fr">
  3.  
  4. <head>
  5.     <meta charset="utf-8">
  6.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7.     <meta name="viewport" content="width=device-width, initial-scale=1">
  8.     <title>Projet 2</title>
  9.  
  10.     <!-- Bootstrap CSS -->
  11.     <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
  12.  
  13.     <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  14.     <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  15.    <!--[if lt IE 9]>
  16.            <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.3/html5shiv.js"></script>
  17.            <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
  18.        <![endif]-->
  19.    <style>
  20.        .box {
  21.            border: 1px red solid;
  22.            padding: 10px;
  23.        }
  24.    </style>
  25. </head>
  26.  
  27. <body>
  28.    .
  29.    <div class="container">
  30.        <div class="row">
  31.            <div id="users">
  32.                <legend>Liste des utilisateurs</legend>
  33.                <div class="status">
  34.  
  35.                </div>
  36.                <div class="row">
  37.                    <!-- est affiché comme ça -->
  38.                    <div class="col-md-6 box" id="box-id">
  39.                        <div id="name">name (username) <br></div>
  40.                        <div id="email">email <br></div>
  41.                        <div id="adress">street suite à city (zipcode) <br></div>
  42.                        <div id="localisation"> <br></div>
  43.                        <div id="phone">phone <br></div>
  44.                        <div id="website">website <br></div>
  45.                        <div id="company">company_name</div>
  46.  
  47.                    </div>
  48.                </div>
  49.            </div>
  50.        </div>
  51.    </div>
  52.  
  53.  
  54.    <!-- jQuery -->
  55.    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  56.    <!-- Bootstrap JavaScript -->
  57.    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  58.    <script>
  59.        $(function () {
  60.            var statut = $('.status');
  61.        
  62.            // $(".status").text("Chargement en cours ...");
  63.            $.ajax({
  64.                type:'GET',
  65.                url: 'https://jsonplaceholder.typicode.com/users',
  66.                 dataType : 'json',
  67.                 timeout: 4000,
  68.                 success: function (result) {
  69.                     // for(i = 0; i<result.length ; i++ ){
  70.                     //     $('#name').html(result[i].name);
  71.                     //     $('#email').html(result[i].email);
  72.                     //     $('#adress').html(result[i].address);
  73.                     //     $('#localisation').html(result[i].address.geo.lat + ' (lat) ').append(result[i].address.geo.long + ' (long)');
  74.                     //     $('#phone').html(result[i].phone);
  75.                     //     $('#website').html(result[i].website);
  76.                     //     $('#company').html(result[i].company.name);
  77.                     //     console.log(result[i].company.name);
  78.                     // }
  79.                     for(i = 0 ; i<result.length;  i++ ){
  80.                         $('#box-id').clone().appendTo($('.status'));
  81.                        
  82.                     }
  83.                    
  84.                 },
  85.                 error: function() {
  86.                     statut.text("RIP une erreur est survenue");
  87.                 }
  88.             });              
  89.         });
  90.  
  91.  
  92.     </script>
  93. </body>
  94.  
  95. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement