summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorRobert Newson <rnewson@apache.org>2011-02-15 13:33:16 +0000
committerRobert Newson <rnewson@apache.org>2011-02-15 13:33:16 +0000
commit4cf6e057d49677b35454f4ab4cb8acd7114bdf95 (patch)
treedb6927273ae36fe29560ac3e93934ce3d1051306 /share
parentafabf978ba3beb8693d6cb0b56561e91d5d52579 (diff)
Only accept application/json from jquery.couch.js
Since Filipe's fix for parsing the accepted content types at r1041103, returns from $.ajax could return a 302 that redirects to an HTML page. Functions like activeTasks() expect JSON and barf when fed HTML. git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1070885 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share')
-rw-r--r--share/www/script/jquery.couch.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/share/www/script/jquery.couch.js b/share/www/script/jquery.couch.js
index 8d86b679..9d814fd4 100644
--- a/share/www/script/jquery.couch.js
+++ b/share/www/script/jquery.couch.js
@@ -87,6 +87,9 @@
options = options || {};
$.ajax({
type: "GET", url: this.urlPrefix + "/_session",
+ beforeSend: function(xhr) {
+ xhr.setRequestHeader('Accept', 'application/json');
+ },
complete: function(req) {
var resp = $.httpData(req, "json");
if (req.status == 200) {
@@ -123,6 +126,9 @@
$.ajax({
type: "POST", url: this.urlPrefix + "/_session", dataType: "json",
data: {name: options.name, password: options.password},
+ beforeSend: function(xhr) {
+ xhr.setRequestHeader('Accept', 'application/json');
+ },
complete: function(req) {
var resp = $.httpData(req, "json");
if (req.status == 200) {
@@ -140,6 +146,9 @@
$.ajax({
type: "DELETE", url: this.urlPrefix + "/_session", dataType: "json",
username : "_", password : "_",
+ beforeSend: function(xhr) {
+ xhr.setRequestHeader('Accept', 'application/json');
+ },
complete: function(req) {
var resp = $.httpData(req, "json");
if (req.status == 200) {
@@ -638,6 +647,7 @@
var commit = options.ensure_full_commit;
delete options.ensure_full_commit;
return function(xhr) {
+ xhr.setRequestHeader('Accept', 'application/json');
xhr.setRequestHeader("X-Couch-Full-Commit", commit.toString());
};
}