How do I use JavaScript to store "XHR finished loading" messages in the console in Chrome? -
i'm looking way use javascript store debug messages appear in chrome console when xmlhttprequests performed. example output provided below:
thanks in advance!
you cannot read console messages javascript. not able read these messages.
however, using same general concept john culviner's answer add “hook” ajax requests on page, can detect events in javascript cause these messages appear.
(function() { var origopen = xmlhttprequest.prototype.open; xmlhttprequest.prototype.open = function(method, url) { this.addeventlistener('load', function() { console.log('xhr finished loading', method, url); }); this.addeventlistener('error', function() { console.log('xhr errored out', method, url); }); origopen.apply(this, arguments); }; })();
this overwrites every xhr object's open
method new function adds load
, error
listeners xhr request. when request completes or errors out, functions have access method
, url
variables used open
method.
you can more useful method
, url
passing them console.log
if wish.
Comments
Post a Comment