From c095bc9a2e0cd35aef2af7ffcc5d13be19355855 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 6 Nov 2014 10:39:58 -0500 Subject: [PATCH] feature(load) rm xhr.responseText overwriting --- lib/client/load.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/client/load.js b/lib/client/load.js index 02cce63b..2f747b4d 100644 --- a/lib/client/load.js +++ b/lib/client/load.js @@ -195,14 +195,17 @@ var Util, DOM; Events.add('readystatechange', xhr, function(event) { var TYPE_JSON, type, data, isContain, notText, - xhr = event.target; + xhr = event.target, + OK = 200; if (xhr.readyState === 4 /* Complete */) { Images.clearProgress(); TYPE_JSON = 'application/json'; type = xhr.getResponseHeader('content-type'); - if (xhr.status === 200 /* OK */) { + if (xhr.status !== OK ) { + Util.exec(p.error, xhr); + } else { data = xhr.response; notText = p.dataType !== 'text', isContain = ~type.indexOf(TYPE_JSON); @@ -212,16 +215,6 @@ var Util, DOM; Util.exec(p.success, data, xhr.statusText, xhr); } - /* file not found or connection lost */ - else { - /* if html given or something like thet - * getBack just status of result - */ - if (type && type.indexOf('text/plain') !== 0) - xhr.responseText = xhr.statusText; - - Util.exec(p.error, xhr); - } } });