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

How to use APIs with JavaScript Forum

View Course

451 points
5311e7c6631fe97bd6002e26_409611399
Submitted by
peterj2k13
over 3 years ago

What in layman terms is the purporse of the 'false' section when making a request

Hi guys,
I just had a general question to ensure I understood the components of the code fully. That is in the code

xhr.open("GET", "http://www.codecademy.com/", false);

what is the purpose of the 'false'. I tried to find an answer through google with very little success, but from what I understood the false is in order to say he script SHOULDN'T send a request to the server, and continue it's execution without waiting for the reply?

Thanks in advance


1 vote

permalink

Hey,
the third parameter is optional and it says if the connection should be asynchronous or synchronous.
true is asynchronous request, this is default
false is synchronous
there is a lot of explanation for this, e.g. https://tle.wisc.edu/blend/facilitate/communicate?q=blend/facilitate/communicate

588 points
C17f8d9cdca6f0fc575dfcaec34bc02d?s=140&d=retro
Submitted by
knecht
about 3 years ago


0 votes

permalink

If you say false, it means that the exercise will wait until it gets a response from the server.

639 points
E7bb2a1e54ecf45e7e1e93d8b71e5355?s=140&d=retro
Submitted by
blue_horse8
about 3 years ago