Ajax-loader-large-white
How to use APIs with JavaScript
Requests

All right! Let's see if you can make that request to codecademy.com all on your lonesome.

Instructions

Go ahead and do three things:

  1. Create a variable called xhr and set it equal to new XMLHttpRequest().
  2. Call open xhr and pass it three arguments: "GET" (the type of request you'd like to make), "http://www.codecademy.com/" (the URL), and false (this means the exercise will wait until it gets a response from the server).
  3. Call .send() on xhr. We've already taken care of the console.log()s for you!
?
Stuck? Get a hint! Hint
Get live, fast support from Codecademy Advisors when you get stuck. Learn more.

To open the website, you'll just need

variable_name = new XMLHttpRequest();
variable_name.open("GET", "URL", false);

where variable_name is xhr and 'URL' is 'http://www.codecademy.com/'.

script.js