[英]405 error in ajax post (Method Not Allowed)
我有一个问题。 当我发送表单时,我收到 405 错误。 我不明白为什么。 在控制台中我看到“错误”
我的代码:
useEffect(() => {
if (Object.keys(data).length) {
let xhr = new XMLHttpRequest()
xhr.open('POST', 'https://test-1a68b-default-rtdb.firebaseio.com/', true)
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
xhr.responseType = 'json'
xhr.send(JSON.stringify(data))
xhr.onreadystatechange = function () {
if (xhr.readyState < 4)
console.log('Loading')
else if (xhr.readyState === 4) {
if (xhr.status === 200 && xhr.status < 300)
console.log('Success')
else
console.log('Error')
}
}
}
}, [data])
您是否有对此 URL 的写入(发布)访问权限,似乎没有。 或者 URI 没有那个 POST 端点,处理程序。 检查您的服务器端日志、Web 服务器配置。
在这里不能多说,因为无法检查请求和测试代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.