Advertisement
MarcosNakamine

Jquery + Json - Estdos e Cidades brasileiras

Jul 7th, 2016
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.63 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Document</title>
  6.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
  7. <script>
  8.     // http://labs.myn.com.br/2012/12/json-cidades-e-estados-brasileiros.html
  9.     $(function(){
  10.         $.ajax({
  11.             dataType: "json", // define o tipo de arquivo
  12.             url: 'estados.json', // arquivo contendo os dados do json
  13.             success: function(e){ // quando o arquivo terminar de fazer download executa essa função
  14.                 console.log(e.estados[0].sigla);
  15.                 console.log(e.estados[0].nome);
  16.             }
  17.         });
  18.     });
  19. </script>
  20. </head>
  21. <body>
  22.  
  23. </body>
  24. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement