couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jasondav...@apache.org
Subject svn commit: r1094181 - /couchdb/trunk/share/www/script/jquery.couch.js
Date Sun, 17 Apr 2011 18:22:43 GMT
Author: jasondavies
Date: Sun Apr 17 18:22:42 2011
New Revision: 1094181

URL: http://svn.apache.org/viewvc?rev=1094181&view=rev
Log:
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.

Modified:
    couchdb/trunk/share/www/script/jquery.couch.js

Modified: couchdb/trunk/share/www/script/jquery.couch.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/jquery.couch.js?rev=1094181&r1=1094180&r2=1094181&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/jquery.couch.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/jquery.couch.js [utf-8] Sun Apr 17 18:22:42 2011
@@ -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