luci-base: xhr.js: fix timeout setting with IE 11
authorJo-Philipp Wich <jo@mein.io>
Sat, 28 Apr 2018 20:55:08 +0000 (22:55 +0200)
committerJo-Philipp Wich <jo@mein.io>
Sat, 5 May 2018 19:16:53 +0000 (21:16 +0200)
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>
modules/luci-base/htdocs/luci-static/resources/xhr.js

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