我的PHP腳本沒有通過POST從獲取任何內容。我究竟做錯了什麼?提取 - 發送POST數據
使用Javascript:
fetch("http://127.0.0.1/script.php", {
method: "post",
body: "inputs=" + JSON.stringify({param: 7})
}).then(response => response.json()).then(response => {
console.log(response);
});
的script.php:
echo "\nprinting POST:\n";
print_r($_POST);
echo "\nprinting GET:\n";
print_r($_GET);
die();
控制檯:
印刷POST:陣列()
印刷GET:陣列()
查看瀏覽器的開發者工具。你將能夠看到請求和迴應,這應該有助於弄清楚發生了什麼問題。 – MyiEye