luci-base: xhr.js: fix timeout setting with IE 11

Internet Explorer 11 requires the timeout to be applied after the open()
call, otherwise an invlaid state exception will be raised

Fixes aa6c97154 ("luci-base: extend xhr.js")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2018-04-28 22:55:08 +02:00
parent 6a1cdca345
commit 34821b15a5

View file

@ -54,11 +54,11 @@ XHR = function()
else else
url += '?' + code; url += '?' + code;
xhr.open('GET', url, true);
if (!isNaN(timeout)) if (!isNaN(timeout))
xhr.timeout = timeout; xhr.timeout = timeout;
xhr.open('GET', url, true);
xhr.onreadystatechange = function() xhr.onreadystatechange = function()
{ {
if (xhr.readyState == 4) { if (xhr.readyState == 4) {
@ -92,10 +92,11 @@ XHR = function()
callback(xhr); callback(xhr);
} }
xhr.open('POST', url, true);
if (!isNaN(timeout)) if (!isNaN(timeout))
xhr.timeout = timeout; xhr.timeout = timeout;
xhr.open('POST', url, true);
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhr.send(code); xhr.send(code);
} }