Please consider this code line which is a part of an AJAX request to embed an HTML contact form inside some webpage.
ajax.open("GET", "html/contact_form.html", false);
What is the meaning of the “false” there? How does it help us send the request or even to the programmer to understand the already simple essense of this code line?
ajax is an XMLHttpRequest, the third argument is, as the documentation states, a boolean flag as to whether the request should be made asynchronously or not. This defaults to
wouldn’t we want any AJAX request to be
I mean, is there any benefit to prevent it’s default asyncronous behavior?
You are confusing AJAX with XMLHttpRequest. Or rather, you’re calling every rectangle a square.
Sometimes you may want to halt processing of the page until you get a response.
I didn’t call every rectangle a square; I think it’s a bad metaphore
I think I’ve confused AJAX with JAX.
Any AJAX is a JAX but not any JAX is an AJAX.
I mean, “JAX” isnt really a thing.
Generally speaking, Things calling AJAX requests are wrapped around an XMLHttpRequest (this is nowadays obfuscated down the
fetch tree). But not all XMLHttpRequests are Asynchronous. As technology has evolved, speeds have increased, computers have become more powerful, the threading of browsers allows them to do more concurrently, we’ve moved towards asynchronous ways of coding.
Agreed. For example, order processing should NEVER be an asynchronous process as you don’t want to complete the order until you’re sure you’ve been paid.