var te = function () {
console.log('te is called');
fetch('https://wx.ireien.com/Ceshi.php', {
method: 'post',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
},
body: JSON.stringify({a: 7, str: 'Some string: &=&'})
})
.then(res=>res.json())
.then(res => console.log(res));
}
var te2 = function () {
console.log('te2 is called');
var data = new FormData();
data.append("course", JSON.stringify({a: {c: 1, b: 'aaaa'}}));
fetch('https://wx.ireien.com/Ceshi.php', {
method: 'post',
body: data
})
.then(res=>res.json())
.then(res => console.log(res));
}
te
post true JSON to server- te2 post a form instead
//For te2 use
var_dump($_POST);
//For te use
file_get_contents('php://input');