AJAX
$.ajax({
type: 'POST',
data: {"doc-id":doc},
url: '../src/update_docs.php',
dataType:"json",
In php
$_POST['doc-id'] //224
Fetch API
fetch('/src/project.php/',{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
credentials: 'same-origin',
body:{"doc-id":doc},
})
In php
$_POST['doc-id'] //Undefined array index
I have tried many different combinations, such as JSON.stringify, which still results in the same. Is there a way I can send the data with the same method in the curly brackets but allow php to get the index?
question from:
https://stackoverflow.com/questions/65641388/php-undefined-array-index-from-fetch-api-but-works-fine-through-ajax 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…