p5-plack-debugger
p5-plack-debugger copied to clipboard
Improve timing for AJAX initialization/handling
- The
Plack.Debugger
javascript gets loaded - The
Plack.Debugger
hooks into the jQuery global AJAX handlers which send events (_:ajax-send
,_:ajax-complete
), however the consumer of these events is not handling them yet. - The
Plack.Debugger
sends off an AJAX request to get the debugging data for the current page (and with that, find out if it needs to handle any AJAX requests or not) - Another AJAX call happens on the page triggering the jQuery global handlers which in turn trigger our events (which are not yet being handled)
- The
Plack.Debugger
AJAX call in #3 succeeds and it loads the data and then turns on AJAX request handling (with the_:ajax-tracking-enable
event).
I can see two possible solutions to this problem right now, not 100% sure which is the best approach yet though.
- We buffer all un-handled AJAX calls within our jQuery global hooks and then once AJAX handling is enabled we process that buffer.
or
- We load the debugging data synchronously (
{async : false}
) essentially blocking the other AJAX requests from coming in before we know if we want to handle them.
The former is likely the "correct" way to do this, but the later is easier and debatably no less "correct" just not as nice.
The first one can be easily accomplished using $.Deferred
, I can take a look at it once I finish with lazy rendering.
Keep in mind please that we are trying to support jQuery 1.2.6 at the earliest and 1.4.1 at the latest, so $.Deferred might not be an option.
Sent from my iPhone
On Oct 12, 2014, at 21:19, Aziz Yuldashev [email protected] wrote:
The first one can be easily accomplished using $.Deferred, I can take a look at it once I finish with lazy rendering.
— Reply to this email directly or view it on GitHub.