Skip to content

Instantly share code, notes, and snippets.

@gunaevart
Last active January 25, 2017 12:34
Show Gist options
  • Save gunaevart/4c79caad2a000d13a2d6f8eddb60c4cc to your computer and use it in GitHub Desktop.
Save gunaevart/4c79caad2a000d13a2d6f8eddb60c4cc to your computer and use it in GitHub Desktop.
Отправка данных через $.ajax
$('#Fsubmit').click(function(){
var Fname = document.querySelector('#Fname').value;
var Ffio = document.querySelector('#Ffio').value;
var Fphone = document.querySelector('#Fmail').value;
var Fmail = document.querySelector('#Fmail').value;
if(Fname.length >= 5 && Ffio.length >= 5){
$.ajax({
url: 'submit.php', // куда посылаем запрос
type: "POST",
data:
{
Fname:Fname,
Ffio:Ffio,
Fphone:Fphone,
Fmail:Fmail
},
success: function(data)
{ // что делаем в случае успеха, в data лежит ответ от сервера
alert(data); // выводим ответ в окно браузера
//перезагружаем страницу для очистки формы
document.location.href = document.location.href;
}
});
}else{
alert('Введите Имя и фамилия полностью!');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment