The code below prints the console log onto the page. It logs gets and responses from server like:
14:15:17 GMT+0000 (GMT Standard Time) Submitting HTTP GET request to http...
14:15:22 GMT+0000 (GMT Standard Time) Received HTTP response: {..
14:15:17 GMT+0000 (GMT Standard Time) Submitting HTTP GET request to http...
14:15:22 GMT+0000 (GMT Standard Time) Received HTTP response: {..
Instead of displaying these onto the page I would like to count every response and request so you see a a number starting at 1 and ending when it ends, could be any number. This is to show the user that something is happening without showing them all the response and get data.
function logHttpResponse(response) {
var now = new Date();
var logger = document.getElementById('log');
var logMessage = now.toTimeString() + " Received HTTP response: " + JSON.stringify(response);
console.log = function (logMessage) {
if (typeof logMessage == 'object') {
logger.innerHTML += (JSON && JSON.stringify ? JSON.stringify(logMessage) : String(logMessage)) + '<br />';
} else {
logger.innerHTML += logMessage + '<br />';
}
}
}
and html:
<div id="log"></div>