JSON response format error - red dot\bullet before response

旧街凉风 提交于 2019-11-26 11:22:21

问题


I am sending an AJAX request expecting JSON response. However, the returned JSON is preceded with a red dot\\bullet which is causing a parse error.

Here is a screenshot from Postman: \"enter

The dot is not shown on Raw or Preview display, only on Pretty.

In Chrome Dev Tools Network tab it appears under Response. Preview is shown normally as if the dot isn\'t there.

\"enter

\"enter


回答1:


As mentioned in a comment before: In Chrome, red dots usually represent non-printable special unicode characters.

Please check your server side code to prevent outputting those characters




回答2:


If your files are encoding with UTF-8, better to encode them with UTF-8 without BOM. This can be easily done through notepad++. The steps are as follows,

  1. Open your files in notepad++.
  2. Go to Encoding option on the file menu.
  3. Then select the option "convert to UTF-8 without BOM".

This may resolve your problem.




回答3:


You need to clear you object buffer on server side. I am using PHP as my server side language and I faced similar problem and the solution was cleaning my buffer using ob_clean();




回答4:


i had the same problem and fixed this by converting the file from utf-8 to utf-8 without BOM




回答5:


I was faced red dots problem in my ajax response I tried a lot of solution but doest work for me after then I tried ob_clean() function I got the solution I solved my problem using ob_clean() inside the constructor method

function __construct()
{
    ob_clean();
}


来源:https://stackoverflow.com/questions/23511275/json-response-format-error-red-dot-bullet-before-response

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!