Making a better form using JavaScript
In this part of the chapter we are going to add some new features to our little module. These features are intended to make a better form, such as avoiding a full page reload by sending the form using AJAX or checking that some text has been introduced before sending it. All these are good features, though not every form needs to make use of these features. It's up to us to decide when to implement them.
But enough chat for now, work is awaiting us!
Send the form using jQuery AJAX
This is not going to be as hard as it may first seem, thanks to the powerful
jQuery features. What steps do we need to take to achieve AJAX form sending?
First, open our default_tmpl.php
file. Here we are going to
add an ID to our button, and change it a bit, from this:
<input type="submit" name="send" value="Send" class="sc_button"/>
to this:
<input type="button" name="send...