Submit Form and Do a Bunch of Tasks in Order Sequentially
I am somewhat new to jquery so this may be a really simple question for some of you experts. I have a form that I process with jquery. In the script, I do a bunch of tasks in order as seen below. Most of it works except for updating a div with an incremented counter value that I get from a database table. I don't see the value on the screen, but it's there when I do a page source.
Is there a way to do a wait after each of these tasks to finish before the next is done? Should I be enclosing each of these tasks into some type of code block? Thanks for your help.
-
var $j = jQuery.noConflict();
$j(document).ready(function(){
$j("form#submit").submit(function() {
//Get form data
//Do some form validation
//Show a loading image
$j('.loading').show();
//Insert the form data into a database table using php page
//Update div1 on page with data from database table
//Zero out the fields in the form
//Update div2 on page with an incremented counter value from database table
//Hide the loading image
$j('.loading').hide();
return false;
});
});