Browse Source

updated parse json in js fetch

Piotr Labudda 8 years ago
parent
commit
cffb724cc7
1 changed files with 10 additions and 1 deletions
  1. 10 1
      SE/se-lib/TableAjax.php

+ 10 - 1
SE/se-lib/TableAjax.php

@@ -2934,7 +2934,16 @@ class TableAjax extends ViewAjax {
 								}).join(','),
 							})
 						}).then(function (response) {
-							return response.json()
+							return response.text()
+						}).then(function (responseText) {
+							try {
+								// json = response.json() // BUG: error trafia do catch promisów, zamiast aktualnego bloku
+								// -- obiekt response pewnie jest powiązany z Promisem z fetch
+								// -- response.json() zwraca Promise tak samo jak response.text()
+								return JSON.parse(responseText)
+							} catch (e) {
+								throw responseText
+							}
 						}).then(function (result) {
 							if ('success' == result.type) {
 								p5UI__notifyAjaxCallback(result)