XMLHttpRequest返回控制台错误

时间:2018-04-26 16:14:20

标签: javascript java xmlhttprequest httprequest

我试图从java后端到javascript前端获取一个数组。当我尝试获取该数组时,我收到一条错误,指出:" localhost:4242 / decks:仅支持协议方案的交叉源请求:http,data,chrome,chrome-extension,https.localhost:4242 /甲板:仅支持协议方案的交叉原始请求:http,数据,chrome,chrome-extension,https。"

function httpGetAsync(theUrl, callback) {
let xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function () {
    if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
        callback(xmlHttp.responseText);
};
xmlHttp.open("GET", theUrl, true);
xmlHttp.send(null);
}

function getDeck() {
httpGetAsync('localhost:4242/decks', function (response) {
    response.forEach(function (deckName) {
        console.log(deckName);
    });
});
}

有人愿意帮助我吗?

0 个答案:

没有答案