Magento – Magento2 Trigger ajax call after Full page load

ajaxmagento2.2

I am using Magento 2.2.1, I am trying to trigger ajax call after Full page load. I tried with below scripts but no luck. Did anyone faced this issue and found any solution for it.

window.load
document.ready
<script type="text/x-magento-init">

Best Answer

var chkReadyState = setInterval(function() {
    if (document.readyState == "complete") {

        // finally your page is loaded.
        // Your ajax call here!! 
        clearInterval(chkReadyState);
        // Clear interval to avoid multiple ajax calls
    }
}, 100);
Related Topic