vuejs2 - vuejs - sending post data to php -


i using due-resource send data php:

var data = {name: "abc", rank: "mid range"};  this.$http.post('../../static/php/savedata.php',       {postdata: json.stringify(data)})       .then((response) => {         console.log(response);       }); 

then process , send data savedata.php test:

<?php $postdata = json_decode(file_get_contents('php://input'),true); $rank = $posteddata['rank'];  $arr = array('status'=>'ok','rank'=>$rank); echo json_encode($arr); ?> 

i null rank. tried other ways in php:

$postdata = json_decode($post['postdate'],true); 

or

$postdata = $post['postdate']; 

all of them give me null. missing here?

i figured out wrong.

because data object, need to:

this.$http.post('../../static/php/savedata.php',json.stringify(data)) 

instead of:

this.$http.post('../../static/php/savedata.php',{postdata: json.stringify(data)}) 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -