I am trying to make a chat program, but am stuck on probably the most simple aspect of php. I have the following code in app.js
var msg = "123";
$.post('index.php', {send: msg});
and the following in index.php
<?php
switch($_SERVER['REQUEST_METHOD'])
{
case 'GET':
echo "<script type='text/javascript'>alert('GET');</script>";
break;
case 'POST':
$msg = $_POST['send'];
echo "<script type='text/javascript'>alert('POST');</script>";
}
?>
The code only alerts me about the 'GET' request I receive when loading the page. Whenever I call the $.post function in app.js nothing happens. I don't know if there's an issue with the server or if I linked to my index.php file wrong in the request?