File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ {
4+ function fetchJSON ( url , cb ) {
5+ const xhr = new XMLHttpRequest ( ) ;
6+ xhr . open ( 'GET' , url ) ;
7+ xhr . responseType = 'json' ;
8+ xhr . onload = ( ) => cb ( xhr . response ) ;
9+ xhr . send ( ) ;
10+ }
11+
12+ function main ( ) {
13+ const select = document . getElementById ( 'select-category' ) ;
14+ const ul = document . getElementById ( 'prize-list-container' ) ;
15+
16+ select . addEventListener ( 'change' , ( ) => {
17+ const url = `http://api.nobelprize.org/v1/prize.json?category=${ select . value } ` ;
18+ console . log ( 'url' , url ) ;
19+ } ) ;
20+ }
21+
22+ window . onload = main ;
23+ }
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 " />
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6+ < meta http-equiv ="X-UA-Compatible " content ="ie=edge " />
7+ < title > Exercise</ title >
8+ </ head >
9+ < body >
10+ < select id ="select-category ">
11+ < option disabled selected > Select a category</ option >
12+ < option value ="physics "> physics</ option >
13+ < option value ="chemistry "> chemistry</ option >
14+ < option medicine ="physics "> medicine</ option >
15+ < option value ="peace "> peace</ option >
16+ < option value ="literature "> literature</ option >
17+ < option value ="economics "> economics</ option >
18+ </ select >
19+ < ul id ="prize-list-container "> </ ul >
20+ < script src ="app.js "> </ script >
21+ </ body >
22+ </ html >
You can’t perform that action at this time.
0 commit comments