Why is send so often called as
xhr.send(null)
instead of
xhr.send()
?
W3, MDN, and M
So, if your HTTP request method is GET, then the HTTP client sends data to the server simply by appending it to the request URL (as a so called query string), meaning that the body of the request is gonna stay empty and that is why you need to set the value of that argument to null.
However, if your HTTP request method is POST, then your request data will be placed into the request body, which will be eventually sent to the server via send function.
Cheers!