Permalink
Browse files

Let me know when XHRs fail.

  • Loading branch information...
1 parent 0ffde1c commit 7c3dfec87a32558c2a6a67a7383ea31116ea7f87 @georgebrock committed Jan 31, 2011
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/holygrail.rb
View
@@ -15,7 +15,7 @@ module XhrProxy
def request(info, data="")
context.instance_eval do
xhr(info["method"].downcase, info["url"], data)
- @response.body.to_s
+ [@response.body.to_s, @response.status.to_i]
end
end
end
@@ -31,9 +31,15 @@ module Extensions
this.info = { method: method, url: url };
};
XMLHttpRequest.prototype.send = function(data) {
- this.responseText = Ruby.HolyGrail.XhrProxy.request(this.info, data);
+ var response = Ruby.HolyGrail.XhrProxy.request(this.info, data);
+ this.responseText = response[0];
+ this.status = response[1];
this.readyState = 4;
this.onreadystatechange();
+
+ if(this.status !== 200) {
+ alert("Warning: " + this.status + " response from XHR " + this.info.method + " " + this.info.url);
+ }
};
</script>
JS

0 comments on commit 7c3dfec

Please sign in to comment.