I have something like this: $('#select1').on('change', function() {})
and it works fine. However, I need to run another function after the function has completed.
I thought about taking the function contents, and putting it in a named function, then taking the second function and doing the same, and placing them in the anonymous function:
$('#select1').on('change', function() {
function1 ();
function2 ();
});
However, I was hoping there was another way. The above seems inconsistent with jQuery.
Try this:
$('#select1').on('change', function() {
function1(someVariable, function() {
function2(someOtherVariable);
});
});
function function1(param, callback) {
//...do stuff
callback();
}
Here is where I found that: Call a function after previous function is complete