summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2010-11-15 14:40:28 +0000
committerJo-Philipp Wich <jow@openwrt.org>2010-11-15 14:40:28 +0000
commitbb1af307f771d9c4e25cfa5d64ca50502a0f2f40 (patch)
treea246775a819ab8efff594877584d2329a428b608
parent19d1578077f3364a02e83f561eea0fd95d523f0b (diff)
themes/base: add json decoding to xhr.js
-rw-r--r--themes/base/htdocs/luci-static/resources/xhr.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/themes/base/htdocs/luci-static/resources/xhr.js b/themes/base/htdocs/luci-static/resources/xhr.js
index 7e2e3b090..9ce302683 100644
--- a/themes/base/htdocs/luci-static/resources/xhr.js
+++ b/themes/base/htdocs/luci-static/resources/xhr.js
@@ -56,8 +56,18 @@ XHR = function()
xhr.onreadystatechange = function()
{
+ var json = null;
+ if( xhr.getResponseHeader("Content-Type") == "application/json" ) {
+ try {
+ json = eval('(' + xhr.responseText + ')');
+ }
+ catch(e) {
+ json = null;
+ }
+ }
+
if( xhr.readyState == 4 ) {
- callback( xhr );
+ callback( xhr, json );
}
}