Я хочу взять значение каждого <input/>
и отправить его в виде запроса JSON.
Вот форма.
<form class="formidable">
<p>Date, heure et lieu de naissance</p>
<input type="text" name="day" id="day" placeholder="Jour">
<input type="text" name="month" id="month" placeholder="Mois">
<input type="text" name="year" placeholder="Année">
<input type="text" name="hour" id="hour" placeholder="Heure">
<input type="text" name="minutes" id="minutes" placeholder="minutes">
<input type="text" name="birthCity" placeholder="Ville">
<input type="text" name="birthCountryLabel" placeholder="Pays">
<input type="text" name="birthCountryCode" placeholder="Code postal">
<input type="submit" name="button" value="submit" id="signin-login" onclick="GameJs()">
</form>
Вот то, что я уже пробовал :(Сначала я установил все переменные)
function GameJs() {
xhr = new XMLHttpRequest();
xhr.open('POST', 'url');
xhr.setRequestHeader('Accept', 'application/json');
xhr.onload = function () {
if (xhr.status === 200) {
alert(xhr.responseText);
}
else if (xhr.status !== 200) {
alert('Request failed. Returned status of ' + xhr.status);
}
};
xhr.send(encodeURI(day));
alert(birthCity);
}
Я получаю ответ от своего сервера, но не могу отправить свои <input/>
значения.