File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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+ < title > Document</ title >
7+ </ head >
8+ < body style = "background-color: #212121; color:#fff; ">
9+ 0 UNSENT Client has been created. open() not called yet
10+ 1 OPENED open() has been called.
11+ 2 HEADERS_RECEIVED send() has been called, and headers and status are available
12+ 3 LOADING Downloading; responseText holds partial data.
13+ 4 DONE The operation is complete.
14+ </ body >
15+ < script >
16+ const requestUrl = 'https://api.github.com/users/kanaklatwal'
17+ const xhr = new XMLHttpRequest ( ) ;
18+ xhr . open ( 'GET' , requestUrl )
19+ xhr . onreadystatechange = function ( ) {
20+ console . log ( xhr . readyState ) ;
21+ if ( xhr . readyState === 4 ) {
22+ //Whenever the response come most of the time it comes in string
23+ const data = JSON . parse ( this . responseText ) ;
24+ console . log ( typeof data ) ;
25+ console . log ( data ) ;
26+ console . log ( data . followers ) ;
27+ //console.log(this.responseText);
28+ }
29+ }
30+
31+ // console.log -> debugging tool/ debugger of browser devloper tool/ it inject runtime javascript
32+
33+ // console.log("HERE");
34+ xhr . send ( ) ;
35+ </ script >
36+ </ html >
You can’t perform that action at this time.
0 commit comments