Update jsonCap.js

This commit is contained in:
Val
2018-11-07 16:45:02 -05:00
committed by GitHub
parent df35d95e86
commit f3bf2467bd

View File

@@ -3,7 +3,9 @@ console.log('jsonCap.js has loaded...');
function captureJSON() { function captureJSON() {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.onload = function() { xhr.onload = function() {
var div = document.getElementById('capturedJSON'), var btn = document.getElementsByTag('button')[0],
btnTxt = btn.textContent,
div = document.getElementById('capturedJSON'),
content = '', content = '',
check = div.innerHTML == content; check = div.innerHTML == content;
if (check) { if (check) {
@@ -20,11 +22,13 @@ function captureJSON() {
content += '<td>' + respObj[i].Title + '</td></tr>'; content += '<td>' + respObj[i].Title + '</td></tr>';
if (i == len) content += '</table>'; if (i == len) content += '</table>';
} }
btnTxt = btnTxt.replace('capture', 'hide');
} else { } else {
console.log('Connection to Server succeeded. Content was not received due to error.'); console.log('Connection to Server succeeded. Content was not received due to error.');
} }
} }
div.innerHTML = content; div.innerHTML = content;
btn.textContent = btnTxt;
}; };
xhr.open('GET', 'files/jsonData.json', true); xhr.open('GET', 'files/jsonData.json', true);
xhr.send(); xhr.send();