Axios posting params not read by $_POST

前端 未结 5 811
旧时难觅i
旧时难觅i 2020-11-28 09:25

So I have this code:

axios({
    method: \'post\',
    url,
    headers: { \'Content-Type\': \'application/x-www-form-urlencoded\' },
    data: {
        jso         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-28 10:02

    var params = {
        data1: 'string',
    }
    
    axios.post(url, params).then(function(response) {
        //code here 
    });
    

    or

    axios.post(url, {data1: 'string' }).then(function(response) {
        //code here 
    });
    

    api

    $_POST = json_decode(file_get_contents("php://input"),true);
    echo $_POST['data1'];
    

提交回复
热议问题