Просмотр исходного кода

JSON : utiliser application/json

Les réponses JSON utilisaient indument text/html
Repéré à cause de
https://github.com/marienfressinaud/FreshRSS/issues/306
Alexandre Alapetite 12 лет назад
Родитель
Сommit
b646bd2f08

+ 1 - 0
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);
 	}
 

+ 1 - 0
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);

+ 1 - 0
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);

+ 6 - 10
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;
 					}
 				},