0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

KUSANAGIでキャッシュをオンにしたらJSON parseerror が出た件

Posted at

KUSANAGIでキャッシュ(bcache)をオンにしたらその影響でJSONの値が上手く出力できなかったのでメモ。

今回発生した問題/原因

React(Ajax)を利用してユーザー情報をJSON形式で出力しようとした所、

index.js:502 undefined "parsererror" "SyntaxError: Unexpected token < in JSON at position

と出てしまいうまく出力できなかった。

原因はbcacheをオンにしたことでHTML形式のコメントが挿入されたためでした。

bcache onのときのJSON

[{"name":"username","img":"ex.jpg","url":"https:\/\/ex.com\/}]
<!-- page cached by KUSANAGI. Cache created : 02:50:21(GMT). Expire : 08:50:21(GMT). -->
<!-- CacheID : 678b83dc8f56969d0211179f589ad539 -->

上記の様に1行目のJSONレスポンスに付随して2,3行目にHTML形式のコメントが挿入されます。

KUSANAGIの環境

KUSANAGI Version 8.0.7-2
WORDPRESS
aws

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?