So I have seen a few questions on this matter but none have been applicable to my situation.
As an example, I have a web page that has multiple Javascript files that attach handlers to controls on the page - some of the controls can have multiple handlers from different JS files e.g. A dropdown list has 2 change events. The problem is that the second change function runs before an AJAX request on the first change event has completed.
What I need to do is to run an ajax request on the first change event and IF THAT IS SUCCESSFUL then run the second event. In the past I could have used
async: false
in the ajax request but that has been deprecated.
My hope was to, on the first change event, call
event.stopImmediatePropagation()
and then start it back up again after the ajax request has run. As far as I can see this is not an option.
Then I tried stopping propagation on the first change, before the AJAX is run, and trying to trigger the change event after the AJAX is run, on the control but that causes an infinite loop.
So:
Is there any way to Pause Propagation?
Is there any way to store event handlers for a control and then trigger them later?
Thanks.