diff options
author | Robert Newson <rnewson@apache.org> | 2011-02-16 09:44:00 +0000 |
---|---|---|
committer | Robert Newson <rnewson@apache.org> | 2011-02-16 09:44:00 +0000 |
commit | db57d543e40dc988293ae43cd35ad9d685315203 (patch) | |
tree | 95a531b9948b4f43915d812b74a3f97a5af3837f /share/www | |
parent | 4cf6e057d49677b35454f4ab4cb8acd7114bdf95 (diff) |
Make compatible with jQuery 1.5.x
git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1071191 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www')
-rw-r--r-- | share/www/script/jquery.couch.js | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/share/www/script/jquery.couch.js b/share/www/script/jquery.couch.js index 9d814fd4..a606c875 100644 --- a/share/www/script/jquery.couch.js +++ b/share/www/script/jquery.couch.js @@ -91,7 +91,7 @@ xhr.setRequestHeader('Accept', 'application/json'); }, complete: function(req) { - var resp = $.httpData(req, "json"); + var resp = httpData(req, "json"); if (req.status == 200) { if (options.success) options.success(resp); } else if (options.error) { @@ -130,7 +130,7 @@ xhr.setRequestHeader('Accept', 'application/json'); }, complete: function(req) { - var resp = $.httpData(req, "json"); + var resp = httpData(req, "json"); if (req.status == 200) { if (options.success) options.success(resp); } else if (options.error) { @@ -150,7 +150,7 @@ xhr.setRequestHeader('Accept', 'application/json'); }, complete: function(req) { - var resp = $.httpData(req, "json"); + var resp = httpData(req, "json"); if (req.status == 200) { if (options.success) options.success(resp); } else if (options.error) { @@ -394,7 +394,7 @@ dataType: "json", data: toJSON(doc), beforeSend : beforeSend, complete: function(req) { - var resp = $.httpData(req, "json"); + var resp = httpData(req, "json"); if (req.status == 200 || req.status == 201 || req.status == 202) { doc._id = resp.id; doc._rev = resp.rev; @@ -459,7 +459,7 @@ copyDoc: function(docId, options, ajaxOptions) { ajaxOptions = $.extend(ajaxOptions, { complete: function(req) { - var resp = $.httpData(req, "json"); + var resp = httpData(req, "json"); if (req.status == 201) { if (options.success) options.success(resp); } else if (options.error) { @@ -602,6 +602,27 @@ } }); + 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; + }; + function ajax(obj, options, errorMessage, ajaxOptions) { options = $.extend({successStatus: 200}, options); ajaxOptions = $.extend({contentType: "application/json"}, ajaxOptions); @@ -617,7 +638,7 @@ }, complete: function(req) { try { - var resp = $.httpData(req, "json"); + var resp = httpData(req, "json"); } catch(e) { if (options.error) { options.error(req.status, req, e); |