- Framework7 Tutorial
- Framework7 - Home
- Framework7 - Overview
- Framework7 - Environment
- Framework7 Components
- Framework7 - Layouts
- Framework7 - Navbars
- Framework7 - Toolbars
- Framework7 - Search Bar
- Framework7 - Status Bar
- Framework7 - Side Panels
- Framework7 - Content Block
- Framework7 - Layout Grid
- Framework7 - Overlays
- Framework7 - Preloaders
- Framework7 - Progress Bar
- Framework7 - List Views
- Framework7 - Accordion
- Framework7 - Cards
- Framework7 - Chips
- Framework7 - Buttons
- Framework7 - Action Button
- Framework7 - Forms
- Framework7 - Tabs
- Framework7 - Swiper Slider
- Framework7 - Photo Browser
- Framework7 - Autocomplete
- Framework7 - Picker
- Framework7 - Calendar
- Framework7 - Refresh
- Framework7 - Infinite Scroll
- Framework7 - Messages
- Framework7 - Message Bar
- Framework7 - Notifications
- Framework7 - Lazy Load
- Framework7 Styling
- Framework7 - Color Themes
- Framework7 - Hairlines
- Framework7 Templates
- Framework7 - Templates Overview
- Framework7 - Auto Compilation
- Framework7 - Template7 Pages
- Framework7 Fast Clicks
- Framework7 - Active State
- Framework7 - Tap Hold Event
- Framework7 - Touch Ripple
- Framework7 Useful Resources
- Framework7 - Quick Guide
- Framework7 - Useful Resources
- Framework7 - Discussion
Ajax Form Submit
Description
Framework7 allows you to automatically send data using Ajax by using the following two ways −
When the user submits the form or submit event is triggered on form programmatically.
When the user modifies any form field or change event triggered on form programmatically.
Send form data on submit
To enable Ajax form and send the form data on clicking Submit, automatically, you need to add the ajax-submit class to form. After the user submits the form, Ajax will automatically send the form data using the following rules −
Form data will be sent to the file or the URL mentioned in action attribute of the form.
Request method will be similar as mentioned in the method attribute of the form.
Content type will be the same as mentioned in the enctype attribute of the form. If not mentioned by default, it is application/x-www-form-urlencoded.
Send form data on input change
We can submit the form data when the user makes any changes in the form fields by using ajax-submit-onchange class as shown below −
<form action = "send.html" method = "GET" class = "ajax-submit-onchange"> ... </form>
When the user modifies any form field, form data will be sent automatically using Ajax with same rules as discussed above.
Ajax submit event
To get actual XHR response from the file/URL where you sent data, you can use special events as shown below −
S.No | Event & Description | target |
---|---|---|
1 | submitted This event will be triggered after successful Ajax request. |
Form Element <form class = "ajax-submit"> |
2 | beforeSubmit
This event will be triggered right before the Ajax request. |
Form Element <form class = "ajax-submit"> |
3 | submitError This event will be triggered on Ajax request error. |
Form Element <form class="ajax-submit"> |