I am having an issue when I am using a post request on an PHP file and I am passing simple keys and values to post. For example say key = productId
and value = 123
.
<?php
$data_back = json_decode(file_get_contents('php://input'));
return $data_back;
I am receiving nothing. Please assist.
Check how is your request created. It must be POST and php://input is not available for enctype="multipart/form-data"
Problem may be json_encode()
receiving invalid JSON. Check for json_decode
error and/or check if the output from file_get_contents('php://input')
is really empty.
in PHP file you can catch post request variabile just using $_POST array.
<?php
$data_back = $_POST;
return $data_back;
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.