From b646bd2f084483bc95b279be3175c77174fbeb89 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 1 Dec 2013 17:50:35 +0100 Subject: [PATCH] JSON : utiliser application/json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les réponses JSON utilisaient indument text/html Repéré à cause de https://github.com/marienfressinaud/FreshRSS/issues/306 --- app/controllers/indexController.php | 1 + app/views/entry/bookmark.phtml | 1 + app/views/entry/read.phtml | 1 + public/scripts/main.js | 16 ++++++---------- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index b3ae40847..8ca730d0f 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -260,6 +260,7 @@ class indexController extends ActionController { $res['reason'] = Translate::t ('invalid_login'); } + header('Content-Type: application/json; charset=UTF-8'); $this->view->res = json_encode ($res); } diff --git a/app/views/entry/bookmark.phtml b/app/views/entry/bookmark.phtml index d175e10ed..1c8214bc4 100755 --- a/app/views/entry/bookmark.phtml +++ b/app/views/entry/bookmark.phtml @@ -1,4 +1,5 @@ a").attr("href"), @@ -109,8 +108,7 @@ function mark_favorite(active) { url: url, data : { ajax: true } }).done(function (data) { - var res = $.parseJSON(data), - $b = active.find("a.bookmark").attr("href", res.url), + var $b = active.find("a.bookmark").attr("href", data.url), inc = 0; if (active.hasClass("favorite")) { active.removeClass("favorite"); @@ -119,7 +117,7 @@ function mark_favorite(active) { active.addClass("favorite").find('.bookmark'); inc++; } - $b.find('.icon').replaceWith(res.icon); + $b.find('.icon').replaceWith(data.icon); var favourites = $('.favorites>a').contents().last().get(0); if (favourites && favourites.textContent) { @@ -591,11 +589,9 @@ function init_persona() { url: url_login, data: {assertion: assertion}, success: function(res, status, xhr) { - var res_obj = $.parseJSON(res); - - /*if (res_obj.status === 'failure') { + /*if (res.status === 'failure') { alert (res_obj.reason); - } else*/ if (res_obj.status === 'okay') { + } else*/ if (res.status === 'okay') { location.href = url_freshrss; } },