, ( ) . , .
1. " ",
, ,
.
2. ( CSS)
/ / , .
3. -
(.. HTML-
).
,
" ", , - :
submitHandler: function(form)
{
$(form).ajaxSubmit(
{
beforeSend: function()
{
$('sample-form button[type="submit"]').attr('disabled', true);
},
success: function()
{
$("#sample-form").addClass('submitted');
}
});
}
2, , "" CSS , . ".ajaxSubmit" , , . http://jquery.malsup.com/form/
, "" "" CSS- .
.sample-form .message {
display: none;
}
.sample-form.submitted .message {
display: block;
padding: 25px 30px;
background: transparent;
font: 300 18px/27px 'Open Sans', Helvetica, Arial, sans-serif;
text-align: center;
}
, , 3 HTML , , javascript-.
<form action="sample-form-process.php" method="post" id="sample-form-1" class="sample-form">
<fieldset>
<section>
<label class="input">
<input type="text" name="name" id="name" placeholder="Your name">
</label>
</section>
<section>
// next form input field...
</section>
</fieldset>
<footer>
<p class="text-center">
<button type="submit">Fill the form to download!</button>
</p>
</footer>
<div class="message">
<p>Thank you for your info! Bla bla bla...</p>
</div>
</form>
Notice how we added the “submitted” class to our request form after a successful callback to the form and how we used CSS to distinguish ourselves from the “hide” and “show” states of our message. Finally, use the “div” to hold our message block for viewing on the Internet.
We hope this helps you improve your thinking and problem-solving skills when processing events using AJAX forms.
source
share