端口8888 net :: ERR_CONNECTION_REFUSED

时间:2014-08-06 16:28:24

标签: javascript xmlhttprequest

尝试调用Web服务侦听端口8888时出现以下问题:

GET http://localhost:8888/rauco/oxygen/1/1/last net::ERR_CONNECTION_REFUSED functions.misc.js:43
Uncaught SyntaxError: Unexpected end of input functions.misc.js:46

function.misc.js:

function get_last_oxygen(location, start_time, end_time)
{
    var xmlHttp = null;
    var oxy_url = 'http://localhost:8888/' + location + '/oxygen/1/1/last';
    xmlHttp = new XMLHttpRequest();
    xmlHttp.open( "GET", oxy_url, true );
    xmlHttp.send( null );// line 43
    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4) {
            var json = JSON.parse(xmlHttp.responseText);//line 46
            var oxy = document.getElementById('oxygen');
            oxy.innerHTML = json.oxygen;
            get_oxygen_range(location, start_time, end_time);
            //alert(xmlHttp.status + ' ' + xmlHttp.responseText);
       }
    }
}

1 个答案:

答案 0 :(得分:0)

如果它在浏览器中运行,请尝试将url从localhost更改为127.0.0.1。如果它有效,则表示您的环境未将localhost解析为127.0.0.1