Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKelby Nylander
Full Stack JavaScript Techdegree Student 9,455 PointsExample 2 of sync xhr.open('GET', url, false)?
I know it is an example of blocking code and not how we should code, but in the second example of the synchronous coding on like 3 it says xhr.open('GET', url, false); I am just starting to get comfortable with the basics of XMLHttpRequests but the 'false' is new to me. Can anyone explain? I was not able to gain much from just looking at the MDN page on the subject.
1 Answer
Jason Larson
8,361 PointsThe false is for the optional value for making the request asynchronous. It is true by default, so that may be why you haven't seen it.
From the MDN page:
async
Optional
An optional Boolean parameter, defaulting to true, indicating whether or not to perform the operation asynchronously. If this value is false, the send() method does not return until the response is received. If true, notification of a completed transaction is provided using event listeners. This must be true if the multipart attribute is true, or an exception will be thrown.