Skip to content
Browse files

made error conform to the expectations of clients by returning xhr as…

… the first parameter to the error callback
  • Loading branch information...
1 parent 93faa28 commit 1771c4d0ae693ae923e1ce298f4a02e6597281c8 Nathan committed Sep 22, 2009
Showing with 3 additions and 4 deletions.
  1. +3 −4 lib/couchdb/http_client.js
View
7 lib/couchdb/http_client.js
@@ -19,24 +19,23 @@ HttpClient.prototype = (function() {
opts.url = uri;
opts.type = verb;
- var data = JSON.stringify(opts.data) || "";
+ var data = opts.data || "";
if (["delete","get"].some(function(x) { return x === verb.toLowerCase(); })){
data = undefined;
}
- //$.ajax(opts);
var req = new XMLHttpRequest();
req.open(verb, uri, false);
req.send(data);
- if (req.status == 200 && opts.success){
+ if (req.status >= 200 && req.status < 300 && opts.success){
var results = req.responseText;
if (opts.dataType && opts.dataType.toLowerCase() === "json"){
results = JSON.parse(results);
}
opts.success(results);
} else if (opts.error) {
- opts.error(req.responseText, req.status);
+ opts.error(req, req.responseText, req.status);
}
},
get: function(uri, options){

0 comments on commit 1771c4d

Please sign in to comment.
Something went wrong with that request. Please try again.