From d4198ceeb3c539a5f0eceb21df12f1f68ddac97d Mon Sep 17 00:00:00 2001
From: Commander-lol <ljcapitanio@gmail.com>
Date: Sun, 2 Nov 2014 19:51:55 +0000
Subject: [PATCH] Fixed error function not being fired by reversing method call
 order. Also fixed previously unknown bug where an error would be fired for a
 304 response (and presumably others)

---
 js/tinyDOM.js | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/js/tinyDOM.js b/js/tinyDOM.js
index 7def556..1e29fac 100644
--- a/js/tinyDOM.js
+++ b/js/tinyDOM.js
@@ -122,14 +122,17 @@
 
 		req.onreadystatechange = function(){
 			if(req.readyState > 1){
-				if(req.status === 200){
+				if(req.status >= 200 && req.status < 400){
 					if (req.readyState === 4 && _this.exists(params.success)){
 						params.success(req.response, req);
 					}
 				} else {
-					req.abort();
-					if(_this.exists(params.error)){
-						params.error({status: req.status, message: req.statusText}, req);
+					if(!_this.exists(req.td_hasAborted) || !req.td_hasAborted){
+						if(_this.exists(params.error)){
+							params.error({status: req.status, message: req.statusText}, req);
+						}
+						req.td_hasAborted = true;
+						req.abort();
 					}
 				}
 			}
-- 
GitLab