Skip to content

Commit

Permalink
fixed sending json back to an HTML ajax request, and just send the sn…
Browse files Browse the repository at this point in the history
…ippet if it is an HTML ajax request
  • Loading branch information
remy committed Jan 17, 2013
1 parent 3dabc9d commit 8ffd937
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lib/handlers/bin.js
Expand Up @@ -577,24 +577,28 @@ module.exports = Observable.extend({


this.formatHistory(bins, format, function (err, history) {
if (acceptsJSON || req.ajax) {
if (acceptsJSON) {
res.send(history);
} else {
helpers.render('history', {
bins: history,
by_user: req.params.user ? ' by ' + req.params.user : ''
},
function (err, html) {
res.render('list', {
list_history: html,
jsbin: jsbin,
scripts: [
"/js/vendor/jquery.js",
"/js/vendor/pretty-date.js",
"/js/render/saved-history-preview.js"
],
is_production: helpers.production
});
if (req.ajax) {
res.send(html);
} else {
res.render('list', {
list_history: html,
jsbin: jsbin,
scripts: [
"/js/vendor/jquery.js",
"/js/vendor/pretty-date.js",
"/js/render/saved-history-preview.js"
],
is_production: helpers.production
});
}
});
}
});
Expand Down

0 comments on commit 8ffd937

Please sign in to comment.