Update jsonCap.js
This commit is contained in:
@@ -3,10 +3,12 @@ console.log('jsonCap.js is running...');
|
|||||||
function captureJSON() {
|
function captureJSON() {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.onload = function() {
|
xhr.onload = function() {
|
||||||
if (xhr.status >= 200 && xhr.status < 400) {
|
|
||||||
var div = document.getElementById('capturedJSON'),
|
var div = document.getElementById('capturedJSON'),
|
||||||
content = '',
|
content = '',
|
||||||
respObj = JSON.parse(xhr.responseText),
|
check = div.innerHTML = content;
|
||||||
|
if (check) {
|
||||||
|
if (xhr.status >= 200 && xhr.status < 400) {
|
||||||
|
var respObj = JSON.parse(xhr.responseText),
|
||||||
len = respObj.length,
|
len = respObj.length,
|
||||||
i;
|
i;
|
||||||
console.log(xhr.responseText);
|
console.log(xhr.responseText);
|
||||||
@@ -19,11 +21,11 @@ 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>';
|
||||||
}
|
}
|
||||||
if (div.innerHTML != '') content = '';
|
|
||||||
div.innerHTML = content;
|
div.innerHTML = content;
|
||||||
} 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.');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
xhr.open('GET', 'files/jsonData.json', true);
|
xhr.open('GET', 'files/jsonData.json', true);
|
||||||
xhr.send();
|
xhr.send();
|
||||||
|
|||||||
Reference in New Issue
Block a user