From bb1af307f771d9c4e25cfa5d64ca50502a0f2f40 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 15 Nov 2010 14:40:28 +0000 Subject: [PATCH] themes/base: add json decoding to xhr.js --- themes/base/htdocs/luci-static/resources/xhr.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 ); } } -- 2.11.0