Page 62 - JavaScript
P. 62

removePreloader();
           } else {
             // the request isn't finished, add the preloader
             addPreloader()
           }

         };

         xmlhttp.open('GET', your_file.php, true);
         xmlhttp.send();


        Listening to AJAX events at a global level



         // Store a reference to the native method
         let open = XMLHttpRequest.prototype.open;

         // Overwrite the native method
         XMLHttpRequest.prototype.open = function() {
             // Assign an event listener
             this.addEventListener("load", event => console.log(XHR), false);
             // Call the stored reference to the native method
             open.apply(this, arguments);
         };


        Read AJAX online: https://riptutorial.com/javascript/topic/192/ajax






















































        https://riptutorial.com/                                                                               19
   57   58   59   60   61   62   63   64   65   66   67