summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs/luci-static
diff options
context:
space:
mode:
Diffstat (limited to 'modules/luci-base/htdocs/luci-static')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/xhr.js19
1 files changed, 11 insertions, 8 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/xhr.js b/modules/luci-base/htdocs/luci-static/resources/xhr.js
index 62b525ebb0..25a90e7254 100644
--- a/modules/luci-base/htdocs/luci-static/resources/xhr.js
+++ b/modules/luci-base/htdocs/luci-static/resources/xhr.js
@@ -65,12 +65,8 @@ XHR = function()
if (xhr.readyState == 4) {
var json = null;
if (xhr.getResponseHeader("Content-Type") == "application/json") {
- try {
- json = JSON.parse(xhr.responseText);
- }
- catch(e) {
- json = null;
- }
+ try { json = JSON.parse(xhr.responseText); }
+ catch(e) { json = null; }
}
callback(xhr, json, Date.now() - ts);
@@ -90,8 +86,15 @@ XHR = function()
xhr.onreadystatechange = function()
{
- if (xhr.readyState == 4)
- callback(xhr, null, Date.now() - ts);
+ if (xhr.readyState == 4) {
+ var json = null;
+ if (xhr.getResponseHeader("Content-Type") == "application/json") {
+ try { json = JSON.parse(xhr.responseText); }
+ catch(e) { json = null; }
+ }
+
+ callback(xhr, json, Date.now() - ts);
+ }
}
xhr.open('POST', url, true);