From 862d78c1d96a22ae215ec272e6f0d07b374421bf Mon Sep 17 00:00:00 2001
From: Di Peng
Date: Fri, 5 Aug 2011 14:22:23 -0700
Subject: doc(xhr): add e2e test for JSONP error handling
- add e2e tests
- refactor the example by removing clear button and simplifying the code
---
src/service/xhr.js | 46 +++++++++++++++++++++++++++++++++++++---------
1 file changed, 37 insertions(+), 9 deletions(-)
(limited to 'src/service/xhr.js')
diff --git a/src/service/xhr.js b/src/service/xhr.js
index 40be270e..224bc57a 100644
--- a/src/service/xhr.js
+++ b/src/service/xhr.js
@@ -115,16 +115,21 @@
var self = this;
this.fetch = function() {
- self.clear();
+ self.code = null;
+ self.response = null;
+
$xhr(self.method, self.url, function(code, response) {
self.code = code;
self.response = response;
+ }, function(code, response) {
+ self.code = code;
+ self.response = response || "Request failed";
});
};
- this.clear = function() {
- self.code = null;
- self.response = null;
+ this.updateModel = function(method, url) {
+ self.method = method;
+ self.url = url;
};
}
FetchCntl.$inject = ['$xhr'];
@@ -134,15 +139,38 @@
-
-
-
- sample
- buzz
+
+
+
+
+
code={{code}}
response={{response}}
+