Whenever I try the request I'm finding that the information isn't being sent to the server. I checked the network in inspection and I'm receiving a status of 200, but for some reason it just won't recognize the post is set. Any help would be massively appreciated
Here's my javascript
const getLocationInfo = async (lat, lng) => {
const payload = {
coordinateData: coordinateData
};
console.log(JSON.stringify(payload))
try{
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
});
if(response.ok){
const responseData = await response.json()
console.log(responseData)
} else {
const errorResponse = await response.text();
console.error('Error:', response.status, errorResponse)
}
} catch(error){
console.error('Error:', error)
}
}
getLocationInfo(100, 100)
And here's the beginning of the PHP code that. Only the beginning is significant because it always just defaults to the "else" statement
if (isset($_POST['coordinateData'])) {
////all the code that is skipped
Thank you for any advice or pointers you can give. I've spent the last 8 hours googling and searching for any errors in my code and tried many different things.