Advertisement
apl-mhd

Jquery ajax

Nov 2nd, 2018
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.70 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <!--suppress ALL -->
  3. <html>
  4. <head>
  5.     <title></title>
  6.  
  7.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  8.  
  9.  
  10.  
  11. </head>
  12. <body>
  13.  
  14. <ul id="info"></ul>
  15.  
  16. <script type="text/javascript">
  17.  
  18.     var $list = $('#info');
  19.  
  20.     $(function () {
  21.  
  22.         $.ajax({
  23.             type: 'GET',
  24.             dataType: 'json',
  25.             url: 'info.json',
  26.             success: function (datas) {
  27.  
  28.                 $.each(datas, function (i, data) {
  29.  
  30.                     $list.append( '<li>'+  data.name  +'</li>');
  31.  
  32.                     console.log(data.age);
  33.                 })
  34.  
  35.             }
  36.         });
  37.  
  38.  
  39.     })
  40.  
  41. </script>
  42. </body>
  43. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement