发生这种错误,会导致接收不到服务端返回的数据
Uncaught DOMException: Failed to read the responseText property from XMLHttpRequest: The value if only accessible if the object’s responseType is ‘’ or ‘text’ (was arraybuffer)
- ArrayBuffer 字节数组,通常在其他语言中称为“byte array”
Uncaught DOMException: Failed to read the ‘responseText’ property from ‘XMLHttpRequest’: The value is only accessible if the object’s ‘responseType’ is ‘’ or ‘text’ (was ‘json’)
Failed to construct ‘URL’: Invalid URL
error Uncaught SyntaxError: Failed to construct ‘WebSocket’: The URL ‘[object Object]’ is invalid
iframe.getAttribute('src') to just frame.srcvar base = 'http://localhost:6001/'var src = iframe.getAttribute('src') // 'iframe.html?id=*&viewMode=story'new URL(src, base)
wx.request
wx.request中的“responseType”项只有两种选项
- ‘’
- ‘text’,之前一直用的 ‘json’,将json修改成text就可以正常收到数据了
排除点,检查返回的数据的Content-Type 类型
wx.request({url: 'http://localhost:8000/v1/user',data: {},header: {'content-type': 'application/json'},responseType : 'json',success (res) {console.log(res)}});
