Chrome & # 8594; Check item & # 8594; Network (XHR) & # 8594; Tab Preview (HTML)

I am having a problem with this preview tab in the network section. When the HTML returns, I see the raw HTML in both the preview and the response. Sometimes, but very rarely, I HTML is displayed correctly on the Preview tab.

Am I doing something wrong or is it just a Chrome bug?

thanks

+6
source share
2 answers

I also tested this. What for me was adding the http header.

header('HTTP/1.1 500 Internal Server Error'); 

Then, of course, the correct layout formatting. But the status code was what I needed to convince chrome to do a preview.

+5
source

The issue was resolved by adding the correct Content-Type header. If its text-html , then it will display the contents as if it were plain text, regardless of what you send from the server. I had the same problem and it was solved using the power output type in the $ .ajax parameters. When I changed it to application/json and now it is nicely formatted.

+1
source

Source: https://habr.com/ru/post/915971/


All Articles