7

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

Mladen Janjetovic
  • 13,844
  • 8
  • 72
  • 82
  • Since this is the first result on google for the search terms I put in, I'd also like to know. I've noticed Slim framework typically has the rendered preview, but when I just do a vardump it doesn't. I think it has something to do with ensuring proper markup such as the doc type, html, head, body elements. – Dustin Graham Jun 19 '12 at 16:11

2 Answers2

5

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.

Dustin Graham
  • 2,054
  • 1
  • 20
  • 24
  • Great, I have tried and it works, but I have a problem when I am using this in Zend. I want to get debug message in preview tab as HTML, because chasing the error cause in html code is just frustrating. This error code header will do the job when error shows up, but when there is no error, this header line is just undesirable. Maybe some try-catch will solve this, but still searching for some solution similar to this one but with something more appropriate liek i.e. header('HTTP/1.1 200 Internal Server Error'); But it seems like only ERROR header force the HTML preview to work. Cheers – Mladen Janjetovic Jun 20 '12 at 10:48
1

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.

lukasz
  • 867
  • 1
  • 8
  • 17