1、问题
源:url:http://localhost:8099/api/test
const xhr = new XMLHttpRequest(); xhr.open('post', url, false); xhr.setRequestHeader("Content-type","application/json"); var str = JSON.stringify(uid) xhr.send(str); const res = JSON.parse(xhr.responseText); console.info(res); return res;
浏览器报错:
Failed to execute 'send' on 'XMLHttpRequest': Failed to load
2、解决办法:
url:http://实际IP:8099/api/test
因为在流浪器访问,所有IP地址不能写成localhost,要改成实际的ip地址
标签:load,XMLHttpRequest,xhr,send,Failed,报错 From: https://www.cnblogs.com/wwssgg/p/17622850.html