Jump to content

AbbyM

New Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by AbbyM

  1. I am creating a contact form using php. This is what the app.js code looks like const form = document.querySelector('form'); statusTxt = form.querySelector('.button__area span'); form.onsubmit = (e) => { e.preventDefault() statusTxt.style.display = "block" var xhttp = new XMLHttpRequest(); // create xml object xhttp.open("POST", "message.php", true); xhttp.onload = () => { if (xhttp.readyState == 2 && xhttp.status == 200) { let response = xhttp.response; console.log(response) } } xhttp.send(); } the php code is just supposed to echo sth: <?php echo "This message is from message.php" ?> However, I am getting this error: I understand it has to do with the headers, but I have no idea how to edit them to allow a post request. app.js:18 POST http://127.0.0.1:5500/message.php 405 (Method Not Allowed) How do i about it?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.