aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-01 17:50:35 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-01 17:50:35 +0100
commitb646bd2f084483bc95b279be3175c77174fbeb89 (patch)
tree90d1370c8449a2e8bc361cd4e63c26d27a82c09a
parentc9c068115d17132ddcdf2194d216533823831896 (diff)
JSON : utiliser application/json
Les réponses JSON utilisaient indument text/html Repéré à cause de https://github.com/marienfressinaud/FreshRSS/issues/306
-rwxr-xr-xapp/controllers/indexController.php1
-rwxr-xr-xapp/views/entry/bookmark.phtml1
-rwxr-xr-xapp/views/entry/read.phtml1
-rw-r--r--public/scripts/main.js16
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 @@
<?php
+header('Content-Type: application/json; charset=UTF-8');
if (Request::param ('is_favorite')) {
Request::_param ('is_favorite', 0);
diff --git a/app/views/entry/read.phtml b/app/views/entry/read.phtml
index e909d47f4..af360ed0c 100755
--- a/app/views/entry/read.phtml
+++ b/app/views/entry/read.phtml
@@ -1,4 +1,5 @@
<?php
+header('Content-Type: application/json; charset=UTF-8');
if (Request::param ('is_read')) {
Request::_param ('is_read', 0);
diff --git a/public/scripts/main.js b/public/scripts/main.js
index 0c0e013e1..5cac3c561 100644
--- a/public/scripts/main.js
+++ b/public/scripts/main.js
@@ -40,8 +40,7 @@ function mark_read(active, only_not_read) {
url: url,
data : { ajax: true }
}).done(function (data) {
- var res = $.parseJSON(data),
- $r = active.find("a.read").attr("href", res.url),
+ var $r = active.find("a.read").attr("href", data.url),
inc = 0;
if (active.hasClass("not_read")) {
active.removeClass("not_read");
@@ -50,7 +49,7 @@ function mark_read(active, only_not_read) {
active.addClass("not_read");
inc++;
}
- $r.find('.icon').replaceWith(res.icon);
+ $r.find('.icon').replaceWith(data.icon);
//Update unread: feed
var feed_url = active.find(".website>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;
}
},