There is a code:
<!DOCTYPE html> <script> function Ajax() { var xhr = new XMLHttpRequest(); var formData = new FormData(document.getElementById('send-form')); xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { document.getElementById("demo").innerHTML = xhr.responseText; } } xhr.open("POST", "search.php", true); xhr.send(formData); } </script> <form id="send-form" method="POST"> <input type="search" name="search"> <input type="submit" onclick="Ajax()" value="Поиск"> </form> <div id="demo"></div> The problem is that the code is working, but it displays the result for a fraction of seconds and disappears. What could be the problem?