XMLHttpRequest js webview android xhr.status = 0 xhr.readyState = 1

时间:2019-03-31 08:34:05

标签: javascript android webview xmlhttprequest

returns xhr.status = 0 and xhr.readyState = 1  xhr.responseText = undefined

但仍返回状态0读取readyState 1 也许我有未完成的东西,或者标志设置不正确?

webView.setWebViewClient(new WebViewClient() {
            public void onPageFinished(WebView view, String url) {
                webView.loadUrl("javascript: document.getElementById('gender-male').click();" +
                        "var xhr = new XMLHttpRequest();"+
                        "xhr.open('GET', 'http://vazazi.ru/regnoref.php',true);"+
                        "xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');"+
                        "xhr.send();"+
                        "xhr.onreadystatechange = function() {if (xhr.readyState === 4&& xhr.status === 200) {} else {}};"+
                        "var test = xhr.responseText;"+
                        "var arr = (test).split(/s*-s*/);" +
                        "var pass = (arr[1]);" +
                        "var mail = (arr[0]);" +
                        "var name = (arr[2]);" +
                        "var last = (arr[3]);"+
                       
                        "function b2() {document.getElementById('first-name').value = name;}setTimeout(b2,6000);"+
                        "function s2() {document.getElementById('last-name').value = last;}setTimeout(s2,7000);"+
                        "function d3() {document.getElementById('email').value = mail;}setTimeout(d3,8000);");



            }

        });

0 个答案:

没有答案