<form id="settings" method="POST" action="savesettings.php" onsubmit="sendForm(this);">
   <p class="settings">
     <label class="text">Логин администратора:</label>
     <br><input type="text" name="username" required>
  </p>
  <p>
    <label class="text">Пароль администратора:</label>
    <br><input type="text" name="password" required>
  </p>

  <p><input type="submit" value ="Сохранить" ></p>
</form>
xhr = new XMLHttpRequest();
function getXMLHttp() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	}
	return new ActiveXObject('Microsoft.XMLHTTP');
};


function sendForm(form) {
	event.preventDefault();
	xhr = getXMLHttp();
	xhr.open('POST', $(form).attr("action"), true);
	xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	var formdata = new FormData(form); 
	xhr.send(formdata);
	xhr.onreadystatechange = function () {
		if (xhr.readyState == 4) {
			//xhr.response - тут ответ от обработчика
		}
	};
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js