PHP没有';看不到REACT发送的请求

PHP没有';看不到REACT发送的请求,php,reactjs,Php,Reactjs,我正在尝试从react向PHP发送POST请求,以下是我的代码: function getPhp(){ var xhr = new XMLHttpRequest() xhr.addEventListener('load', () => { console.log(xhr.responseText) }) xhr.open('POST', 'http://localhost/anima/index.php') xhr.send(JSO

我正在尝试从react向PHP发送POST请求,以下是我的代码:

function getPhp(){
    var xhr = new XMLHttpRequest()

    xhr.addEventListener('load', () => {
      console.log(xhr.responseText)
    })

    xhr.open('POST', 'http://localhost/anima/index.php')

    xhr.send(JSON.stringify({ dt: 'data' }))
}
PHP:

然而,我得到的唯一回应是

Array
(
)

由于$\u请求。我在开发工具中检查了网络,一切正常。

不需要URL查询字符串(
dt=data
),而不是JSON?@Jeto我也尝试过,但没有成功。如果是这样的话,
$\u REQUEST
会显示什么吗?您应该检查浏览器控制台上的
参数
选项卡,而不是
标题
。它显示了什么吗?另外,根据文档,您需要添加以下内容:
xhr.setRequestHeader(“内容类型”,“应用程序/x-www-form-urlencoded”)如果您正在传递url编码的数据。这可能只是一个骗局。@Jeto是的,没错。感谢lota不需要URL查询字符串(
dt=data
),而不是JSON?@Jeto我也试过了,它不起作用。如果是这样的话,
$\u REQUEST
会显示什么吗?您应该检查浏览器控制台上的
参数
选项卡,而不是
标题
。它显示了什么吗?另外,根据文档,您需要添加以下内容:
xhr.setRequestHeader(“内容类型”,“应用程序/x-www-form-urlencoded”)如果您正在传递url编码的数据。这可能只是一个骗局。@Jeto是的,没错。谢谢
Array
(
)