couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [38/50] jquery-couch commit: updated refs/heads/import-master to 66dbcbf
Date Tue, 01 Apr 2014 08:52:43 GMT
Simplify JSON parsing calls.

Thanks to @brainsatwork for the suggestion.  Instead of carrying around a lump
of legacy jQuery 1.4.x $.httpData code, I've simply called $.parseJSON directly.

git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1094181 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/couchdb-jquery-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-jquery-couch/commit/c959bfe6
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-jquery-couch/tree/c959bfe6
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-jquery-couch/diff/c959bfe6

Branch: refs/heads/import-master
Commit: c959bfe63fb958e3b3c114723971c8a78156a66e
Parents: 4f6e343
Author: Jason David Davies <jasondavies@apache.org>
Authored: Sun Apr 17 18:22:42 2011 +0000
Committer: Alexander Shorin <kxepal@gmail.com>
Committed: Sun Apr 17 18:22:42 2011 +0000

----------------------------------------------------------------------
 jquery.couch.js | 34 ++++++----------------------------
 1 file changed, 6 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-jquery-couch/blob/c959bfe6/jquery.couch.js
----------------------------------------------------------------------
diff --git a/jquery.couch.js b/jquery.couch.js
index 71ff6e9..3cec9b8 100644
--- a/jquery.couch.js
+++ b/jquery.couch.js
@@ -145,7 +145,7 @@
             xhr.setRequestHeader('Accept', 'application/json');
         },
         complete: function(req) {
-          var resp = httpData(req, "json");
+          var resp = $.parseJSON(req.responseText);
           if (req.status == 200) {
             if (options.success) options.success(resp);
           } else if (options.error) {
@@ -229,7 +229,7 @@
             xhr.setRequestHeader('Accept', 'application/json');
         },
         complete: function(req) {
-          var resp = httpData(req, "json");
+          var resp = $.parseJSON(req.responseText);
           if (req.status == 200) {
             if (options.success) options.success(resp);
           } else if (options.error) {
@@ -257,7 +257,7 @@
             xhr.setRequestHeader('Accept', 'application/json');
         },
         complete: function(req) {
-          var resp = httpData(req, "json");
+          var resp = $.parseJSON(req.responseText);
           if (req.status == 200) {
             if (options.success) options.success(resp);
           } else if (options.error) {
@@ -652,7 +652,7 @@
             dataType: "json", data: toJSON(doc),
             beforeSend : beforeSend,
             complete: function(req) {
-              var resp = httpData(req, "json");
+              var resp = $.parseJSON(req.responseText);
               if (req.status == 200 || req.status == 201 || req.status == 202) {
                 doc._id = resp.id;
                 doc._rev = resp.rev;
@@ -762,7 +762,7 @@
         copyDoc: function(docId, options, ajaxOptions) {
           ajaxOptions = $.extend(ajaxOptions, {
             complete: function(req) {
-              var resp = httpData(req, "json");
+              var resp = $.parseJSON(req.responseText);
               if (req.status == 201) {
                 if (options.success) options.success(resp);
               } else if (options.error) {
@@ -1001,28 +1001,6 @@
     }
   });
 
-  var httpData = $.httpData || function( xhr, type, s ) { // lifted from jq1.4.4
-    var ct = xhr.getResponseHeader("content-type") || "",
-      xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
-      data = xml ? xhr.responseXML : xhr.responseText;
-
-    if ( xml && data.documentElement.nodeName === "parsererror" ) {
-      $.error( "parsererror" );
-    }
-    if ( s && s.dataFilter ) {
-      data = s.dataFilter( data, type );
-    }
-    if ( typeof data === "string" ) {
-      if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
-        data = $.parseJSON( data );
-      } else if ( type === "script" ||
-                  !type && ct.indexOf("javascript") >= 0 ) {
-        $.globalEval( data );
-      }
-    }
-    return data;
-  };
-
   /**
    * @private
    */
@@ -1041,7 +1019,7 @@
       },
       complete: function(req) {
         try {
-          var resp = httpData(req, "json");
+          var resp = $.parseJSON(req.responseText);
         } catch(e) {
           if (options.error) {
             options.error(req.status, req, e);


Mime
View raw message