aquaballoon

Ajax - getJSON

May 8th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.95 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>TODO supply a title</title>
  5.         <meta charset="UTF-8">
  6.         <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.         <link href="css/bootstrap.css" rel="stylesheet" type="text/css"/>
  8.         <script src="js/jquery/jquery.js" type="text/javascript"></script>
  9.         <script src="js/bootstrap.js" type="text/javascript"></script>
  10.        
  11.         <script>
  12.             $(function(){
  13.                $("button").click(function(){
  14.                   $.getJSON("data.json", function(result){
  15.                       $.each(result, function(id, filed){
  16.                           $("div").append(filed.name +""+ filed.email +"<br>");
  17.                       });
  18.                   });
  19.                });
  20.             });
  21.            
  22.            
  23.         </script>
  24.        
  25.     </head>
  26.     <body>
  27.        
  28.         <button>Click</button>
  29.         <div></div>
  30.     </body>
  31. </html>
Advertisement
Add Comment
Please, Sign In to add comment