Thought I'd try and pass data and get it to return, a bit lost. This is what I've tried
function getAddress(){
const postalcode = this.value;
fetch('locations.php').then(response => response.json()).then(postalcode => console.log(postalcode));
}
$postalcode = $_POST['postalcode'] ?? '';
if (isset($postalcode)) {
header('Content-type: application/json');
return json_encode($postalcode);
}