Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Planet Swapi Uhuy</title>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <script
- src="http://code.jquery.com/jquery-3.3.1.js"
- integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
- crossorigin="anonymous">
- </script>
- </head>
- <body>
- <table border="2" id='tablePlanet'>
- <tr>
- <th>Name</th>
- <th>Rotation Period</th>
- <th>Orbital Period</th>
- <th>Diameter</th>
- <th>Climate</th>
- </tr>
- </table>
- </body>
- <script>
- $(document).ready(function(){
- $.get('https://swapi.co/api/planets/?page=1',function(data){
- var planetData = ''
- $.each(data.results,function(index,item){
- planetData += `<tr>`
- planetData += `<td>${item.name}</td>`
- planetData += `<td>${item.rotation_period}</td>`
- planetData += `<td>${item.orbital_period}</td>`
- planetData += `<td>${item.diameter}</td>`
- planetData += `<td>${item.climate}</td>`
- planetData += `</tr>`
- })
- $('#tablePlanet').append(planetData)
- })
- })
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement