From 7a2f9bf7ad43b70cc27c3b6b2ee16c0500d43aa8 Mon Sep 17 00:00:00 2001 From: Willem Date: Mon, 14 Mar 2016 00:26:00 +0100 Subject: [PATCH] Added json accept header on resouces fetch --- README.md | 3 ++- es5-ff-spa-loader.js | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index dd32978..e103b1d 100644 --- a/README.md +++ b/README.md @@ -216,10 +216,11 @@ Add unit tests for any new or changed functionality. Lint and test your code. ### 0.2.0 * 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. * refined css so question/loader/error are equal. * Added response header check support. +* Added json accept header on assets resources list. ### 0.1.1 * Moved websql delete timeout to cleanServerlUrl for faster boot. diff --git a/es5-ff-spa-loader.js b/es5-ff-spa-loader.js index eb74cd1..c7968b7 100644 --- a/es5-ff-spa-loader.js +++ b/es5-ff-spa-loader.js @@ -26,7 +26,7 @@ /** * FFSpaLoader is an assets loader for single page applications. * 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 */ @@ -330,7 +330,7 @@ * @param {function} cb Error first callback when done. * @private */ - var utilHttpFetch = function (url, cb) { + var utilHttpFetch = function (url, cb, onlyJson) { var startTime = new Date().getTime(); var httpRequest = new XMLHttpRequest(); httpRequest.onreadystatechange = function() { @@ -369,6 +369,9 @@ var headerValue = options.server.header.request[headerKey]; httpRequest.setRequestHeader(headerKey,headerValue); } + if (onlyJson === true) { + httpRequest.setRequestHeader('Accept','application/json'); + } httpRequest.send(); }; @@ -783,7 +786,7 @@ progressBar.done(); }); } - }); + }, true); }; /** @@ -857,7 +860,7 @@ } else { startLoader(clearUi); } - }); + }, true); }; /**