I am currently coding with javascript and I've hit a wall. Javascript FETCH api to POST is this:
('form') is my form #ID in html.
fetch(URL_TO_POST, {
method: 'post',
body: new FormData(document.querySelector('form'))
}).then(response => {
console.log(response);
});
php file:
if( !isset($_POST['email'])){
throw new exception (blabla);
}
URL_TO_POST is like a "validation.php" and inside the code I retrieve some POST informations and do some stuff there. The problem is that I can't throw any exception to the javascript response! Any thoughts on that? Note: I'm not using ajax to post because I'm trying to stay simple and clean with only js code. Thanks!