Why now is not working ajax request?

Made three files:
<div class="one">hi</div>
 <script src="jquery-3.2.1.min.js"></script>
 <script type="text/javascript" src="app.js"></script>

$(function() {
 var data = $('.one').html();
$.ajax({
type:'POST',
 url: 'form.php',
 data: {data: data},
 success: function(data){
alert(data);
}
});
});

if(isset($_POST['data'])) {
 $maks = $_POST['data'] . 'Maksim';
 echo $maks;
 } else {
 echo 'qwewe';
 }

Alert output hi Maxim, but after an hour or two writing code alert is not displayed and is displayed only:
Notice: Undefined index: data in D:\xampp\htdocs\index\form.php on line 28
Maksim
June 10th 19 at 16:23
2 answers
June 10th 19 at 16:25
Seriously? What does javascript or ajax, you have clearly written that the error is in PHP, even listed the place and what exactly is the problem:
Notice: Undefined index: data in D:\xampp\htdocs\index\form.php on line 28

Unknown index data in $_POST is likely
June 10th 19 at 16:27
Apparently you have not correctly specified the path to the file form.php, list the full path from the root of your web project, for example, if you file is in the root then you need to specify:

url: '/form.php',

Find more questions by tags AJAXPHPJavaScript