The simplest ajax request does not work. When you click on the button should be sent a letter. When you click on the button, the first alert is triggered. Then the second alert (data) pops up and it is empty, but the test.php handler does not work. It does not work with both direct and relative paths. Help, I am desperate!
Code
function klikaj() { alert('ok'); var name=3; var phone=6; $.ajax({ url: 'http://exmaple.xyz/test.php', data: {phone:phone, name:name}, type: 'POST', success: function(data){ alert (data); } }); } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> Handler codeecho $_POST['name'];
mail("milllanikev@gmail.com", "My Subject", "Line 1\nLine 2\nLine 3");
There is an assumption that this is due to the single entry point located in index.php
if ($_SERVER['REQUEST_URI'] == '/') { $Page = 'index'; $Module = 'index'; } else { $URL_Path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); $URL_Parts = explode('/', trim($URL_Path, ' /')); $Page = array_shift($URL_Parts); $Module = array_shift($URL_Parts); if (!empty($Module)) { $Param = array(); for ($i = 0; $i < count($URL_Parts); $i++) { $Param[$URL_Parts[$i]] = $URL_Parts[++$i]; } } } if ($Page == 'index') include('page/index.php'); else if ($Page == 'regreg') include('page/regreg.php'); else if ($Page == 'editproject') include('page/editproject.php'); else if ($Page == 'regcom') include('page/regcom.php'); else if ($Page == 'regprofile') include('page/regprofile.php'); else if ($Page == 'addproject') include('page/addproject.php'); else if ($Page == 'delmember') include('page/delmember.php'); else if ($Page == 'addmember') include('page/addmember.php'); else if ($Page == 'account') include('acc/account.php'); else if ($Page == 'search') include('page/search.php'); else if ($Page == 'comm') include('page/comm.php'); else if ($Page == 'mail') include('mail.php');