I am trying to connect to the server using an XMLHttpRequest object to publish data at different times. I create an object and "connect" to the server like this:
var xhr = new XMLHttpRequest(); xhr.open("post", location, true); xhr.send();
And at a later point, I call something like this:
xhr.send("Something to send");
However, looking at the developer's console, it seems that only the initial request has passed (and successfully answered). The second request does not seem to be sent. I am trying to narrow down what could be the problem, so I thought: can the connection be closed after receiving a response? Why should he stay open? So my question is: is the XMLHttpRequest object connection closed after receiving the response? If so, what is the best way to simulate a continuously open connection (to constantly connect?)?
source share