Last active
January 25, 2017 12:34
-
-
Save gunaevart/4c79caad2a000d13a2d6f8eddb60c4cc to your computer and use it in GitHub Desktop.
Отправка данных через $.ajax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#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