2
0
Fork 0

Added json accept header on resouces fetch

This commit is contained in:
Willem 2016-03-14 00:26:00 +01:00
parent efff34774e
commit 7a2f9bf7ad
2 changed files with 9 additions and 5 deletions

View file

@ -216,10 +216,11 @@ Add unit tests for any new or changed functionality. Lint and test your code.
### 0.2.0 ### 0.2.0
* Moved error.style and question.style to css file. * Moved error.style and question.style to css file.
* Change dist with extra css/js folder. * Changed dist with extra css/js folder.
* Added loader progress bar. * Added loader progress bar.
* refined css so question/loader/error are equal. * refined css so question/loader/error are equal.
* Added response header check support. * Added response header check support.
* Added json accept header on assets resources list.
### 0.1.1 ### 0.1.1
* Moved websql delete timeout to cleanServerlUrl for faster boot. * Moved websql delete timeout to cleanServerlUrl for faster boot.

View file

@ -26,7 +26,7 @@
/** /**
* FFSpaLoader is an assets loader for single page applications. * FFSpaLoader is an assets loader for single page applications.
* Its build around the concept the there is only a single static index.html which * Its build around the concept the there is only a single static index.html which
* synces all its assets to local cache for offline and or fast page loads. * synces all its assets to local cache for offline use and or fast page loads.
* *
* @module FFSpaLoader * @module FFSpaLoader
*/ */
@ -330,7 +330,7 @@
* @param {function} cb Error first callback when done. * @param {function} cb Error first callback when done.
* @private * @private
*/ */
var utilHttpFetch = function (url, cb) { var utilHttpFetch = function (url, cb, onlyJson) {
var startTime = new Date().getTime(); var startTime = new Date().getTime();
var httpRequest = new XMLHttpRequest(); var httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function() { httpRequest.onreadystatechange = function() {
@ -369,6 +369,9 @@
var headerValue = options.server.header.request[headerKey]; var headerValue = options.server.header.request[headerKey];
httpRequest.setRequestHeader(headerKey,headerValue); httpRequest.setRequestHeader(headerKey,headerValue);
} }
if (onlyJson === true) {
httpRequest.setRequestHeader('Accept','application/json');
}
httpRequest.send(); httpRequest.send();
}; };
@ -783,7 +786,7 @@
progressBar.done(); progressBar.done();
}); });
} }
}); }, true);
}; };
/** /**
@ -857,7 +860,7 @@
} else { } else {
startLoader(clearUi); startLoader(clearUi);
} }
}); }, true);
}; };
/** /**