Attempting to establish a connection with the server using an XMLHttpRequest object to send data intermittently. The process of creating the object and establishing a connection is as follows:
var xhr = new XMLHttpRequest();
xhr.open("post", location, true);
xhr.send(); //Should the send call be used to open the connection?
Subsequently, a request is made at a later time:
xhr.send("Data to be sent");
However, upon examining the developer console, it appears that only the initial request was successfully processed and responded to. The second request does not appear to be sent. To troubleshoot the issue, the query of whether the connection is closed once a response is received arises; Furthermore, is there a method to keep the connection open continuously to maintain reconnection?