Skip to content

Commit

Permalink
Replace overlooked 'form' parameter in json response with 'html'.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Almdal committed Aug 3, 2010
1 parent 3492f17 commit 4261711
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions lib/gallery.dialog.js
Expand Up @@ -32,7 +32,7 @@
type: "GET",
beforeSend: function(xhr) {
// Until we convert to jquery 1.4, we need to save the XMLHttpRequest object so that we
// can detect the mime type of the reply
// can detect the mime type of the reply
this.xhrData = xhr;
},
success: function(data, textStatus, xhr) {
Expand All @@ -45,7 +45,7 @@
var content = "";
if (mimeType[1] == "application/json") {
data = JSON.parse(data);
content = unescape(data.form);
content = unescape(data.html);
} else {
content = data;
}
Expand Down Expand Up @@ -130,31 +130,31 @@
},
beforeSend: function(xhr) {
// Until we convert to jquery 1.4, we need to save the XMLHttpRequest object so that we
// can detect the mime type of the reply
// can detect the mime type of the reply
this.xhrData = xhr;
},
success: function(data) {
// Pre jquery 1.4, get the saved XMLHttpRequest object
xhr = this.xhrData;
if (xhr) {
var mimeType = /^(\w+\/\w+)\;?/.exec(xhr.getResponseHeader("Content-Type"));

var content = "";
if (mimeType[1] == "application/json") {
data = JSON.parse(data);
} else {
data = {"html": escape(data)};
}
} else {
// Uploading files (eg: watermark) uses a fake xhr in jquery.form.js so
// all we have is in the data field, which should be some very simple JSON.
// Weirdly enough in Chrome the result gets wrapped in a <pre> element and
// looks like this:
// <pre style="word-wrap: break-word; white-space: pre-wrap;">{"result":"success",
// "location":"\/~bharat\/gallery3\/index.php\/admin\/watermarks"}</pre>
// bizarre. Strip that off before parsing.
data = JSON.parse(data.match("({.*})")[0]);
}
if (xhr) {
var mimeType = /^(\w+\/\w+)\;?/.exec(xhr.getResponseHeader("Content-Type"));

var content = "";
if (mimeType[1] == "application/json") {
data = JSON.parse(data);
} else {
data = {"html": escape(data)};
}
} else {
// Uploading files (eg: watermark) uses a fake xhr in jquery.form.js so
// all we have is in the data field, which should be some very simple JSON.
// Weirdly enough in Chrome the result gets wrapped in a <pre> element and
// looks like this:
// <pre style="word-wrap: break-word; white-space: pre-wrap;">{"result":"success",
// "location":"\/~bharat\/gallery3\/index.php\/admin\/watermarks"}</pre>
// bizarre. Strip that off before parsing.
data = JSON.parse(data.match("({.*})")[0]);
}

if (data.html) {
$("#g-dialog").html(unescape(data.html));
Expand Down

0 comments on commit 4261711

Please sign in to comment.