javascript - Why Chrome sometimes makes 2 AJAX requests instead of 1? -
i have encountered strange behaviour of current version of google chrome (44.0.2403.157) on os x.
when ajax (xhr) request method chrome sometimes makes 1 request , - 2 (!).
my code:
var jsurl = 'http://www.some-domain.com/xy.js'; var ajax = new xmlhttprequest(); ajax.withcredentials = true; ajax.open( 'get', jsurl, true ); // async, because sync cannot send cookies ajax.onreadystatechange = function () { var script = ajax.response || ajax.responsetext; if (ajax.readystate === 4) { switch( ajax.status) { case 200: case 304: eval.apply( window, [script] ); // no break on purpose here default: somefunction(); } } }; ajax.send(null);
a screenshot of developer console when 2 requests being made:
server log confirms second request being made - it's not in console.
the headers of second request practically same first 1 - difference value of cookie being changed 3rd request on screen above.
note current version of firefox (40.0.3) on os x doesn't show behaviour - 1 request made here, every time (tested both watching request using firebug (with bfcache requests shown) , watching server logs).
for while thought using send()
vs send(null)
makes difference - when using send()
1 request being made - after more tests see strangeness present both syntaxes.
can give me hint happening here?
Comments
Post a Comment