I'm trying to connect to the server using an XMLHttpRequest object to post data at different times. I create an object and "connect" to the server like so:
var xhr = new XMLHttpRequest();
xhr.open("post", location, true);
xhr.send(); //Is this send call needed to open the connection?
And at a later point in time, I call something like this:
xhr.send("Something to send");
However, looking at the developer console, it seems that only the initial request went through (and successfully responded). The second request doesn't seem to send. I'm trying to narrow down what could be the problem, so I thought: could the connection be closed once the response is received; Why would it be kept open? So, my question: Is the XMLHttpRequest object connection closed once it receives a response? If so, what's the best way to simulate a continuously open connection (to constantly reconnect?)?