Reputation: 8805
I use this little trick to update the current page while the next page is loading. When the user clicks submit, I set an interval timer which does xhr calls to the server to find out how much longer the response is going to take and update the page with this information, thus successfully entertaining the user.
In Firefox and IE this works fine, but it seems in chrome after the form submit happens, the setinterval call will still fire but the xmlhttprequest never actually performs the request. I don't get any errors or exceptions, it just does this
xmlhttp.onreadystatechange = statstatechange;
xmlhttp.open("POST", url, true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send(postdata);
and my statstatechange function never gets called, and I see no requests on the server side, so as far as I can tell the request never gets made.
Any idea how to make chrome do this?
Upvotes: 1
Views: 381
Reputation: 8805
For anybody having the same problem in chrome: it turns out that if you have an iframe on the page, you can fire xhr requests in that iframe and they will continue to work even after the main top level page form has been submitted. So it's a crappy workaround but at least it functions.
Upvotes: 1
Reputation: 2320
try adding these two
xmlhttp.setRequestHeader('Content-length',url.length);
xmlhttp.setRequestHeader('Connection','close');
Upvotes: 0