XMLHttpRequest 发起请求后 绝对url被当成相对url 识别并拼接到了一起

我在页面通过js发起http请求时URL不能被正常识别
JS部分代码

platformurl = "http://127.0.0.1:7777/api/Payh5/getplatform"
var httpRequest1 = new XMLHttpRequest();
httpRequest1.open('get',platformurl,false);
httpRequest1.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
httpRequest1.send();

发起请求后url被当成相对url拼接了

img

百思不得其解

确认是这个代码?看截图网址缺少了http://协议导致的,应该不是这个贴出代码。

get请求不需要设置Content-type,post才会需要。

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632