Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as JavaScript by ylf ( 7 years ago )
const URL_TO_SEND_DATA = 'tyt_url_kyda_otpravlat_daty';

function sendData(data) {
  console.log('Data:', data);
  // https://learn.javascript.ru/fetch
  fetch(
    URL_TO_SEND_DATA,
    {
      method: 'POST',
      body: data,
    },
  );
}

window.onload = function () {
  // получим кновку
  const sendButton = document.getElementById('send');
  // получим поле ввода
  const input = document.getElementById('input');

  // событие на нажатие кнопки в инпуте
  input.onkeypress = (e) => {
    // если Ентер отправм данные
    if (e.key === 'Enter') {
      sendData(input.value);
    }
  }

  // при клике на кнопку отправить отправим
  sendButton.onclick = () => {
    sendData(input.value);
  }
}

 

Revise this Paste

Your Name: Code Language: