I am working on a dynamic online website. In the main form, I have several subforms that can be added and removed dynamically.
<div class='subform'> //form fields <input ...> ... <button class='subform_submit'> </div>
For each subform, I associate an AJAX call on the submit button of the subform as follows:
$('#main').on('click', '.subform_submit', function(){
So, on this page I can have from 0 to 10 subforms depending on the user's choice. I also have a main submit button at the bottom of the page that can transfer these subforms and the main form data together.
$('#main').on('click', '#submit', function(e){ $('.subform_submit').click();
After clicking the main submit button, I want to show the boot image and then show the dialog box (I use bootbox.confirm() here) until all AJAX calls are completed. This dialog box informs the user that the entire form has been submitted, including subforms. But the problem is that each AJAX call can take 2 seconds, and I donβt know how the calls can be until completion. How can I write this main submit button so that it:
- Show downloadable image immediately and
- Hide downloadable image and display dialog box after all AJAX calls are completed?
javascript jquery ajax bootbox
monknom
source share