GET请求
axios.get("http://127.0.0.1/jQuery/Ajax/41.php?act=add&age=34")
.then(function (res) {
console.log(res.data);
})
.catch(function (e) {
console.log(e);
});
PHP获得GET参数
$act=$_GET['act'];
$age=$_GET['age'];
POST请求
axios.post("http://192.168.56.1/wluo/41.php", {
act: "lnj",
name: "teacher"
})
.then(function (res) {
console.log(res.data);
})
.catch(function (e) {
console.log(e);
});
PHP获得POST参数
$rws_post = $GLOBALS["HTTP_RAW_POST_DATA"];
$mypost = json_decode($rws_post);
$act=(string)$mypost->act;
$name=(string)$mypost->name;
PHP返回数据
echo $act;