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.
source share