Pending Requests such as Ajax based pages







Pending Requests

On some websites, the onDocumentComplete event is fired to signify that the site has finished loading, but due to Javascript functions or Ajax, extra content is loaded on the page afterwards. The pending request functionality is a way of knowing when this content is rendered that has been generated after the page has loaded.

The NetworkEvent class has the new method, hasPendingRequests which can be called from inside onDocumentComplete. This will return true if the page still has network requests that are yet to complete.

The NetworkListener class has the method, onDocumentPendingRequestsComplete. This works in the same way that the onDocumentComplete function works, but will fire only when extra content has finished loading if there is any.

The code segment below shows how this is implemented.

See PendingRequests.java in the examples folder for a working demonstration.

IMozillaBrowserCanvas browser;
browser.addNetworkListener( new NetworkAdapter() {
        public void onDocumentComplete( NetworkEvent e ) {
                // The page has finished loading but extra content could still be loaded.
                if ( e.hasPendingRequests() ) {
                        // There is still content to load.
        public void onDocumentPendingRequestsComplete( NetworkEvent e ) {
                // All content on the page has now been loaded.






 Copyright � JadeLiquid Software - www.jadeliquid.com