Chrome -> Inspect element -> Network (XHR) -> Preview Tab (HTML) issue

与世无争的帅哥 提交于 2020-01-12 08:05:10

问题


I am having a problem with that preview tab in network section. When HTML is returned I am seeing the raw HTML in both preview and response. Sometimes, but very rarely, I HTML is rendered properly in Preview tab.

Am I doing something wrong or it's just some Chrome bug?

Thanks


回答1:


I was testing this as well. What did it for me was adding the http header.

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

Then of course some proper markup formatting. But the status code was what I needed to convince chrome to render the preview.




回答2:


Problem is solved when you add a proper Content-Type header. If its text-html then it will display content like it would be normal text no matter what do you send from server. I had the same problem and solved it by force'ing output type in $.ajax options. When i changed it to application/json and its nicely formatted now.



来源:https://stackoverflow.com/questions/10632748/chrome-inspect-element-network-xhr-preview-tab-html-issue

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