1

I'm generating a JSON array for AJAX usage, but for some reason something is automatically surrounding my JSON response with HTML and encoding the characters like so:

<html><body><p>{&quot;this&quot;:&quot;that&quot;}</p></body></html> 

Here is (literally all of) the PHP that is being echoed to produce the JSON:

echo json_encode(array('this' => 'that')); 

I do not have the luxury of setting the header content type to be JSON (as this is a WordPress plugin that I cannot modify, and shouldn't need to). It works fine on my other servers. It's absolutely a server configuration issue either with Apache or PHP. Any ideas?

Closest I found was this, but I don't think it applies to me and I see no solution: https://stackoverflow.com/questions/31844685/apache-reverse-proxy-wraps-json-response-in-html

Thanks!

1 Answer 1

0

Do you have the

@header ("Content-Type: application/json");

It will not allow the proxy to modify the content, as it is not HTML

1
  • Like I said, I can't do that -- this is in a plugin. It works, but I can't do that. Thanks though! Commented Jun 2, 2016 at 17:52

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.