Теперь проблема заключается в том, что я не могу найти подходящий способ использования AJAX для проверки и представления конкретной формы. < /P>
Мой текущий скрипт: < /p>
/
Код: Выделить всё
$('html').on
Код: Выделить всё
$('html').on ('click','.sendit', function (){
Var a = $(this).parent ('form').attr ('id');
a.submit (submit);
});
function submit (){
Var form = $(this);
If (! $(.name).val () || ! $(.email).val () || ! $(.subject).val () || ! $(.message).val ()){
$('.incomp').show ();
} else {
$('.sending').show ();
$.ajax ({
url: form.attr ('action') + "?ajax=true",
type: form.attr ('method'),
data: form.serialize(),
success: finished
});
}
return false;
}
Function finished (response){
response = $.trim (response);
$('.sending').show ();
If (response == "success"){
$('.success').show ();
} else {
$('.error').show ();
}
}
< /code>
Этот скрипт будет очень хорошо отправлять данные формы, но недостаток использования этого: '.show ();' выполнено во всей форме. < /p>
html -код: < /p>
[list][*]Contact
Sending your message. Please wait...
Thanks for sending your message! We'll get back to you shortly.
There was a problem sending your message. Please try again.
Please complete all the fields in the form before sending.
[*]Inquiry
Sending your message. Please wait...
Thanks for sending your message! We'll get back to you shortly.
There was a problem sending your message. Please try again.
Please complete all the fields in the form before sending.
[/list]
Код: Выделить всё
#complaintForm
Подробнее здесь: https://stackoverflow.com/questions/183 ... re-more-th