这就是我的ajax函数,用于将JSON发送到我的PHP:
var myJson={"username":"fsa","name":"fs","lastname":"fdsa","password":"aaa"}
request=new XMLHttpRequest()
request.open("POST", "controller/login.php", true)
request.onload = function () {
if (request.status === 200) {
console.log(request.status)
} else {
console.log(request.status)
}
}
request.setRequestHeader("Content-type", "application/json")
request.send(myJson)
console.log(request.status)返回值“ 200” 所以我认为我没有falso功能吗?
在我的PHP文件上,我将尝试获取我的Json文件。
$test = $_POST;
var_dump($test);
echo($_POST);
die();
,响应为: 数组(0){ } 数组