eLDeR,
document.addEventListener('DOMContentLoaded', function () {
let codeinpit = document.querySelector('#promo');
let price = document.getElementById('price');
let timer;
codeinpit.oninput = function () {
window.clearTimeout(timer);
let code = this.value;
function wait() {
const request = new XMLHttpRequest();
const url = "../action/code.php?code=" + code;
request.open('GET', url);
request.setRequestHeader('Content-Type', 'application/x-www-form-url');
request.addEventListener("readystatechange", () => {
if (request.readyState === 4 && request.status === 200) {
console.log( request.responseText );
}
});
request.send();
// price.innerHTML = code;
}
timer = setTimeout(wait, 3000);
}
});