This forum is now read-only. Please use our new forums at discuss.codecademy.com.

How to use APIs with JavaScript Forum

View Course » View Exercise

325 points
31670098ead44a517570464238ffc4ab?s=140&d=retro
Submitted by
Todd
about 2 years ago

Can someone please tell me what's wrong with my code.

I always get a error message that says:

"NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://www.codecademy.com/'."

and Codecademy says:"Oops, try again. Did you console.log(xhr.status)?"

Here is my code: var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.codecademy.com/", false);
// Add your code below!
xhr.send();
console.log(xhr.status);
console.log(xhr.statusText);


2 votes

permalink

its not the code, its the web address for codecademy. Its looking for http but this site is https. This changed worked for me at least. Good luck!

535 points
Picture
Submitted by
Richard Morales
about 2 years ago

2 Comments

31670098ead44a517570464238ffc4ab?s=140&d=retro Todd about 2 years ago

Oh wow, that helps a loooooot. Thanks for that error, I should have caught that :)

8a93a9b7245bcbe5edc0546d5d046e19?s=140&d=retro yuvaraj about 2 years ago

Thanks...Yeah....I too found out yesterday itself


1 vote

permalink

Who Knew You Had To Use "https" Instead Of... "http."

1424 points
59bd15bddd1ede791c000004_292840222
Submitted by
Gamma YT
about 2 years ago


0 votes

permalink

You need to use "https"

585 points
55c96525e39efe607a000784_727349661
Submitted by
Tr0j4n V1ru5 Coding
about 2 years ago


-5 votes

permalink

Am also getting the following error when I run, even though my code is correct:

Oops, try again. Did you console.log(xhr.status)?

1162 points
8a93a9b7245bcbe5edc0546d5d046e19?s=140&d=retro
Submitted by
yuvaraj
about 2 years ago

2 Comments

Picture Adil Rizvi about 2 years ago

use https as above said

8a93a9b7245bcbe5edc0546d5d046e19?s=140&d=retro yuvaraj about 2 years ago

Thanks...Yeah....I too found out yesterday itself